// Thu, 21 July 2011 // // In this version we will define a general detector // in order to avoid additional definition all the time tha // a detector is added. // We will create a TTree with the VFAT raw data. // // // Sat, 23 July 2011 // // In this version we add informationn on the event // as trigger, timestamp, turbo and slot id... // We have defined a VFATDataArray with those information // defined in the object. // Inside the detectors ttre, those value are extracted from the // first VFAT. // Inside the vfat ttree (raw) they are defined for all // of them as they are (usefull fof check) // // Sun, 24 July 2011 // // In this version we add the geometrical information // associated to each channel. We would like to have something // that can be used for each tyoe of detector. // For this reason we will associate to each detector // X,Y,R Phi coordinate. They will be filled only if they are reasonable. // // Wed, 27 July 2011 // // We modified also the reco. We keep only the tracker detectors and // we add the event info also in the recofile. // // Tue, 28 July 2011 // // New Classes for VFAT and Detector have been defined. // The configuration used has to be inserted in the CONFIGURATION SECTION // // Sun, 31 July 2011 // // We have now the geo containers working properly. // // Wed, 3 Aug 2011 // // We have added the geocontainer also in the clusterization. This // is useful beacause it helps on creating the clusters for more // complex readout (layout). // Additional Geometrical Flips (Horizontal and Vertical) of the detectors // have been added in their definition. I this way it is possible to // adapt them to the used geometry. // // // Sat, 3 Mar 2012 // // We changed the basic scheme of the rd51tb analysys software. // The idea is the following: // 1. EventBuilder -> Convert channels Hits into cluster with spatial coordinate // 2. Track Finder -> Extract the Tracks // 3. Analyzer -> Using the tracks Info, calcutes efficiencies, cluster size,... // // Main Changes in the EventBuilder: // -We add as for the tracks reconstruction the possibility to load the detectors offset // from an external file (without recompiling the code) // -We load the detector and chip configuartion from the external configuartion files #include #include "Riostream.h" #include #include "TObject.h" #include #include "Clustering/Config.hpp" //#include "Loaders/LoaderSettings.hpp" #include "Loaders/LoaderSettings.cpp" //#include "Loaders/LoaderDetectorConf.hpp" #include "Loaders/LoaderDetectorConf.cpp" #include "Loaders/LoaderVFATConf.cpp" #include "Loaders/LoaderOffsetFlipConf.cpp" #include "Mapping/ReadoutType.cpp" #include "Mapping/TotemT2.cpp" #include "Mapping/TotemT1LG.cpp" #include "Mapping/CmsMapping.cpp" #include "Clustering/DataArray_T.cpp" #include "Clustering/GeoDataArray_T.cpp" //#include "Utilities/ColoredMessages.hpp" #include "TClonesArray.h" #include #include #include "TMath.h" #include "TSystem.h" #include "TString.h" #include "TFile.h" #include "TTree.h" #include "TCanvas.h" #include "TH1F.h" #include "TH2F.h" #include "TCut.h" //using namespace std; // Event Builder Routine // The VFAT DAQ creates binary files and the event builder creates a raw data TTree saved on a root file // int rd51_EventBuilderVFAT( const char* rawfilename = "input.dat" , const char* rootfilename = "Events_built.root" , const int readmaxevent = 100000000) { LoaderSettings *LoaderSettings_rd51_EventBuilderVFAT = new LoaderSettings("Setting_EventBuilderVFAT.conf"); if (LoaderSettings_rd51_EventBuilderVFAT->error) gApplication->Terminate(0); string rd51_EventBuilderVFAT_DetectorConfigFile =(LoaderSettings_rd51_EventBuilderVFAT->DetectorConfigFile).c_str(); string rd51_EventBuilderVFAT_DetectorOffsetAndFlipFile=(LoaderSettings_rd51_EventBuilderVFAT->DetectorOffsetAndFlipFile).c_str(); string rd51_EventBuilderVFAT_VFATConfigFile =(LoaderSettings_rd51_EventBuilderVFAT->VFATConfigFile).c_str(); int EBV_Verbose = LoaderSettings_rd51_EventBuilderVFAT->Verbose; int EBV_LoaderSettingsPrintOut = LoaderSettings_rd51_EventBuilderVFAT->LoaderSettingsPrintOut; int EBV_DetectorInfoPrintOut = LoaderSettings_rd51_EventBuilderVFAT->DetectorInfoPrintOut; int EBV_VFATInfoPrintOut = LoaderSettings_rd51_EventBuilderVFAT->VFATInfoPrintOut; int EBV_ChipIdVerbose = LoaderSettings_rd51_EventBuilderVFAT->ChipIdVerbose; int EBV_EfficiencyEstimatorPrintOut = LoaderSettings_rd51_EventBuilderVFAT->EfficiencyEstimatorPrintOut; int EBV_BeampProfiledataPrintOut = LoaderSettings_rd51_EventBuilderVFAT->BeampProfiledataPrintOut; if (EBV_LoaderSettingsPrintOut) { cout << "Detector Configuration File: \t" << rd51_EventBuilderVFAT_DetectorConfigFile << "\n" << "Detector Offset And Flip File:\t" << rd51_EventBuilderVFAT_DetectorOffsetAndFlipFile << "\n" << "VFAT Configuration File: \t" << rd51_EventBuilderVFAT_VFATConfigFile << endl; } // The clusterization is readout dependent. // We prefer to have independent clusterization // Classes for different readout electrodes. // TO UPGRADE: A general definition can be usefull // TClass::GetClass("VFAT2")->IgnoreTObjectStreamer(); // TClass::GetClass("Detector")->IgnoreTObjectStreamer(); // TClass::GetClass("VFATDataArray")->IgnoreTObjectStreamer(); // TClass::GetClass("GeoDataArray")->IgnoreTObjectStreamer(); // TClass::GetClass("Hit")->IgnoreTObjectStreamer(); //---Original TClass::GetClass("Cluster")->IgnoreTObjectStreamer(); TClass::GetClass("GeoCluster")->IgnoreTObjectStreamer(); TClass::GetClass("Track")->IgnoreTObjectStreamer(); if (!rawfilename) rawfilename = "input.dat"; if (!rootfilename) rootfilename = "Events_built.root"; ifstream ifile(rawfilename, ifstream::binary); TFile f(rootfilename,"RECREATE"); //----------TTree Definition ---------------------------------------------------------------- TTree *tree_conf = new TTree("rd51tbconfig","RD51 test beam configuration"); TTree *tree_raw = new TTree("rd51tbraw","RD51 test beam raw data"); //---Original TTree tree("rd51tb","RD51 test beam"); TTree *tree_geo = new TTree("rd51tbgeo","RD51 test beam geometry"); // tree_conf->SetDirectory(gDirectory); // tree_raw->SetDirectory(gDirectory); // tree_geo->SetDirectory(gDirectory); //----------TTree Definition ---------------------------------------------------------------- //-------------- CONFIGURATION (DETECTORS AND VFATS)----------------------------------------- //---------------------------------------------------------- // DETECTOR CONFIGURATION. //---------------------------------------------------------- //--- Loading the detector configuration file and Retrieving the number of detectors LoaderDetectorConf *DetectorConf_rd51_EventBuilderVFAT = new LoaderDetectorConf(rd51_EventBuilderVFAT_DetectorConfigFile); if (DetectorConf_rd51_EventBuilderVFAT->error) gApplication->Terminate(0); Int_t MaxNumbersOfDetDir = DetectorConf_rd51_EventBuilderVFAT->det_NumberOfDetectors; //--- Inizializing the detectors Detector* DET[MaxNumbersOfDetDir]; for (Int_t i=0; idet_Name[i] ; (*DET[i]).ReadoutType = DetectorConf_rd51_EventBuilderVFAT->det_ReadoutType[i] ; (*DET[i]).OffsetHorizontal = DetectorConf_rd51_EventBuilderVFAT->det_xOffset[i] ; (*DET[i]).OffsetVertical = DetectorConf_rd51_EventBuilderVFAT->det_yOffset[i] ; (*DET[i]).FlipHorizontal = DetectorConf_rd51_EventBuilderVFAT->det_xFlip[i] ; (*DET[i]).FlipVertical = DetectorConf_rd51_EventBuilderVFAT->det_yFlip[i] ; (*DET[i]).TotChannels = DetectorConf_rd51_EventBuilderVFAT->det_TotChannels[i] ; (*DET[i]).PossibleHits = DetectorConf_rd51_EventBuilderVFAT->det_PossibleHits[i] ; (*DET[i]).MaxDistInCluster = DetectorConf_rd51_EventBuilderVFAT->det_MaxDistInCluster[i] ; (*DET[i]).PeriodicityInCluster = DetectorConf_rd51_EventBuilderVFAT->det_PeriodicityInCluster[i] ; (*DET[i]).MaxDistPeriodicityInCluster = DetectorConf_rd51_EventBuilderVFAT->det_MaxDistPeriodicityInCluster[i] ; (*DET[i]).MaxNumOfClusters = DetectorConf_rd51_EventBuilderVFAT->det_MaxNumOfClusters[i] ; cout<<"###########\t"<< (*DET[i]).PossibleHits <error) gApplication->Terminate(0); //--- Updating the offsets/flips (the offsets/flips have been written in a //--- different filein order to be completely independent from the main config file) for (Int_t i=0; ixOffset[i]; (*DET[i]).OffsetVertical = OffsetFlip_rd51_EventBuilderVFAT->yOffset[i]; (*DET[i]).OffsetZ = OffsetFlip_rd51_EventBuilderVFAT->zOffset[i]; (*DET[i]).FlipHorizontal = OffsetFlip_rd51_EventBuilderVFAT->xFlip[i]; (*DET[i]).FlipVertical = OffsetFlip_rd51_EventBuilderVFAT->yFlip[i]; } //--- PrintOut of the detector configuration loaded if(EBV_DetectorInfoPrintOut) { cout << "______________________________________________________________________________________________________________" << endl; cout << "Number of Loaded Detectors: " << MaxNumbersOfDetDir << endl; cout << "" << endl; cout << "DetID,ROTyp,Offx,Offy,Offz,Flipx,Flipy,TotChs,PossibleHits,MaxDistInCls,PerInCls,MaxDistPerInCls,MaxNumOfCls,DetName" << endl; cout << "" << endl; for (Int_t i=0; iDump(); //--- Loading the detector configuration for (Int_t i=0; ivfat_ChipId[i] ; (*VFAT[i]).Channels = VFATConf_rd51_EventBuilderVFAT->vfat_Channels[i] ; (*VFAT[i]).DetectorId = VFATConf_rd51_EventBuilderVFAT->vfat_DetectorId[i] ; (*VFAT[i]).DetectorName = VFATConf_rd51_EventBuilderVFAT->vfat_DetectorName[i] ; (*VFAT[i]).DetectorSector = VFATConf_rd51_EventBuilderVFAT->vfat_DetectorSector[i]; (*VFAT[i]).ChipInvert = VFATConf_rd51_EventBuilderVFAT->vfat_ChipInvert[i] ; (*VFAT[i]).ChipOffset = VFATConf_rd51_EventBuilderVFAT->vfat_ChipOffset[i] ; (*VFAT[i]).TurboId = VFATConf_rd51_EventBuilderVFAT->vfat_TurboId[i] ; (*VFAT[i]).SlotId = VFATConf_rd51_EventBuilderVFAT->vfat_SlotId[i] ; } //--- PrintOut of the detector configuration loaded if(EBV_VFATInfoPrintOut) { char hex_ChipId_printout[7]; cout << "______________________________________________________________________________________________________________" << endl; cout << "Number of Loaded VFATs: " << chips_per_evt << endl; cout << "" << endl; cout << "Id,ChipId, Channels, DetectorId, DetectorName ,DetectorSector , ChipInvert, ChipOffset, TurboId, SlotId" << endl; cout << "" << endl; for (Int_t i=0; iSetOwner(kTRUE); } //--- DATA CONTAINER -------------------------------------------------------------------------------------------- //--------------- EVENT INFO --------------------------------------------------- //I define some Event Info. They are defined by the first read chip. struct EventInfo_t { int EventNumber; int TriggerNumber; int TimeStamp; int BunchCounter; int EventCounter; }; EventInfo_t EventInfo; //--------------- EVENT INFO --------------------------------------------------- //--------------- TREEs --------------------------------------------------------- //Define Branches for the clusterized data and for the data in space coordinate tree_geo->Branch("EventInfo" ,&EventInfo.EventNumber ,"EventNumber/I:TriggerNumber/I:TimeStamp/I:BunchCounter/I:EventCounter/I"); for(Int_t i=0; iBranch( (*DET[i]).DetectorName,"TClonesArray",&(gGeoClustVect[i]),32000,1); } //--------------- TREEs --------------------------------------------------------- //-----------END DETECTOR DEFINITION --------------------------------------------------------- //-------------- VFAT DEFINITION ------------------------------------------------------------- // Insert here the number of channels per chip (128 for the VFAT) const Int_t channels_per_chip = (*VFAT[0]).Channels; // Insert here the VFAT chip ID (16 bit). The order used in this array has to be maintened for the next ones, where // invert, offset, detector ID are specified. // TO UPGRADE: The VFAT ID can be extracted by the xml file saved at the end of the acquisition. unsigned short chipID[chips_per_evt]; for (Int_t i=0; iBranch( vfatID_ChipId,"VFAT2",&(VFAT[i]),chips_per_evt,1); tree_conf->GetBranch(vfatID_ChipId)->SetAutoDelete(); } //Define Branches for the vfats raw data tree_raw->Branch("EventInfo" ,&EventInfo.EventNumber ,"EventNumber/I:TriggerNumber/I:TimeStamp/I:BunchCounter/I:EventCounter/I"); char vfatID_string[6]; for(Int_t i=0; iBranch( vfatID_string,"VFATDataArray",&(vfat_data[i]),32000,0); tree_raw->GetBranch(vfatID_string)->SetAutoDelete(); } //-----------END VFAT DEFINITION ------------------------------------------------------------- //------------------------------------------------------------------------------------------- // // FRAME READOUT // //------------------------------------------------------------------------------------------- // Variables derived from the above-mentioned configuration: Int_t readcheck[chips_per_evt]; for(Int_t ichip = 0; ichip < chips_per_evt; ichip++) { readcheck[ichip] = 0; } //cout << "Define DataStructure" << endl; //TO UPGRADE: Define one object with the event charachteristics vs event number. //This will be useful to monitor the data. We should do it in DataArray. struct datastructure { unsigned short bof; unsigned short turboid; unsigned short slotid; unsigned short fullid; unsigned short trignum; unsigned short timestamp; unsigned short bc; unsigned short ec; unsigned short chipid; unsigned short data[8]; unsigned short crc; unsigned short eof; } testdata; const unsigned int framelenght = 38; //Check of data structures and alignment in the machine it is running if (EBV_Verbose ==1 ){ cout << "Size of datastructure on this machine is (should be " << framelenght << "): " << sizeof(datastructure) << endl; cout << "\nChecking Alignment.."; cout << "\ntestdata.bof is at " << reinterpret_cast(&testdata.bof); cout << "\ntestdata.turboid is at " << reinterpret_cast(&testdata.turboid); cout << "\ntestdata.slotid is at " << reinterpret_cast(&testdata.slotid); cout << "\ntestdata.fullid is at " << reinterpret_cast(&testdata.fullid); cout << "\ntestdata.trignum is at " << reinterpret_cast(&testdata.trignum); cout << "\ntestdata.timestamp is at " << reinterpret_cast(&testdata.timestamp); cout << "\ntestdata.bc is at " << reinterpret_cast(&testdata.bc); cout << "\ntestdata.ec is at " << reinterpret_cast(&testdata.ec); cout << "\ntestdata.chipid is at " << reinterpret_cast(&testdata.chipid); cout << "\ntestdata.data[0] is at " << reinterpret_cast(&(testdata.data[0])); cout << "\ntestdata.data[1] is at " << reinterpret_cast(&(testdata.data[1])); cout << "\ntestdata.data[2] is at " << reinterpret_cast(&(testdata.data[2])); cout << "\ntestdata.data[3] is at " << reinterpret_cast(&(testdata.data[3])); cout << "\ntestdata.data[4] is at " << reinterpret_cast(&(testdata.data[4])); cout << "\ntestdata.data[5] is at " << reinterpret_cast(&(testdata.data[5])); cout << "\ntestdata.data[6] is at " << reinterpret_cast(&(testdata.data[6])); cout << "\ntestdata.data[7] is at " << reinterpret_cast(&(testdata.data[7])); cout << "\ntestdata.crc is at " << reinterpret_cast(&testdata.crc); cout << "\ntestdata.eof is at " << reinterpret_cast(&testdata.eof); cout << "\n" << endl; } union { struct datastructure frame; char bytes[framelenght]; } buffer; //--------------------- Cleaning ------------------------------------- //clear all contents for(Int_t ichip = 0; ichip < chips_per_evt; ichip++) { readcheck[ichip] = 0; } // Cleaning all the vfats DataArray for (Int_t i=0; iClear("C"); // Cleaning all the detectors DataArray for (Int_t i=0; iRemoveAllChannels(); // for (Int_t i=0; iRemoveAllChannels(); // Using TClonesArray also for the geo, we have to replace the previous line with the following ones. // tmpgeocluster.RemoveAllChannels(); // for (Int_t i=0; iClear(); // Cleaning all the detectors Clusterization TClonesArray // tmpcluster.RemoveAllChannels(); // for (Int_t i=0; iClear("C"); for (Int_t i=0; iClear("C"); geotmpcluster[i]->RemoveAllChannels(); } //test cluster //ROOT BUG??!?! it seems that if I fill the first event with an //empty TClonesArray (as it was the case with the datafile used //during debugging), you get a crash when you Draw("XXXcl.ch"), //i.e. the union of all the hits of all the cluster. The workaround //here is just a fake filling of the TClonesArray with a cluster that //is after discarded /* FOR THE MOMENT THIS IS REMOVED.. tmpcluster.InsertChannel(0); for (i=0; i= 2) cout << "Reading at file position " << ifile.tellg() << endl; //cout << "Reading frame " << iframe << endl; //---------------------------------------------------------------------------------------- // READING OF THE FRAME //---------------------------------------------------------------------------------------- //cout << "Reading Frame " << iframe << "...." << endl; ifile.read(buffer.bytes, framelenght); //cout << "..Done!" << endl; //---------------------------------------------------------------------------------------- // READING OF THE FRAME //---------------------------------------------------------------------------------------- if (EBV_Verbose >= 2) { char lastfillchar = cout.fill('0'); cout << "\nChecking a VFAT frame..\n" << hex<<"\trk\n"; cout.width(4); cout << buffer.frame.bof << " "; cout.width(4); cout << buffer.frame.turboid << " "; cout.width(4); cout << buffer.frame.slotid << " "; cout.width(4); cout << buffer.frame.fullid << " "; cout.width(4); cout << buffer.frame.trignum << " "; cout.width(4); cout << buffer.frame.timestamp << " "; cout.width(4); cout << buffer.frame.bc << " "; cout.width(4); cout << buffer.frame.ec << " "; cout.width(4); cout << buffer.frame.chipid << " "; cout.width(4); cout << buffer.frame.data[0] << " "; cout.width(4); cout << buffer.frame.data[1] << " "; cout.width(4); cout << buffer.frame.data[2] << " "; cout.width(4); cout << buffer.frame.data[3] << " "; cout.width(4); cout << buffer.frame.data[4] << " "; cout.width(4); cout << buffer.frame.data[5] << " "; cout.width(4); cout << buffer.frame.data[6] << " "; cout.width(4); cout << buffer.frame.data[7] << " "; cout.width(4); cout << buffer.frame.crc << " "; cout.width(4); cout << buffer.frame.eof << "\n" << dec << endl; cout.fill(lastfillchar); } // cout << "Checking frames...." << endl; //cout<<"buffer.frame.bof & 0xFFF0 = "<>4; } Int_t ichip = -1; for (Int_t i = 0; i < chips_per_evt; i++) if (buffer.frame.fullid == chipID[i]) { ichip = i; break; }; ///////////////////////////////////////////////////////////////////////////////////////// // // VFAT RAW DATA ///////////////////////////////////////////////////////////////////////////////////////// if (ichip>= 0) { if ( EBV_ChipIdVerbose ) cout << "VFAT RAW DATA of Chip" << buffer.frame.fullid << " read in event "<< ievent << endl; if (readcheck[ichip] > 1) { cout << "11 Data misalignment error on chip index " << ichip << "\nat file position " << ifile.tellg() << "\nat Chip ID " << buffer.frame.fullid << "\nin detector " <<(*DET[chipdet[ichip]]).DetectorName << "\nVFAT RAW DATA " << "\nEvent Number: " << ievent << endl; errorstatus = 10; break; } // We Fill the Event Info in the VFAT Braches vfat_data[ichip]->InsertEventInfo( ievent, buffer.frame.turboid, buffer.frame.slotid, buffer.frame.trignum, buffer.frame.timestamp, (buffer.frame.bc & 0X0FFF), (buffer.frame.ec & 0X0FF0)>>4); Int_t vfat_lastchanblock = channels_per_chip-16; for(Int_t offset=0; offset < 8; offset++) { Int_t vfat_rightblock = vfat_lastchanblock-(offset<<4); if (buffer.frame.data[offset] & 0x8000) vfat_data[ichip]->InsertChannel(vfat_rightblock+15); if (buffer.frame.data[offset] & 0x4000) vfat_data[ichip]->InsertChannel(vfat_rightblock+14); if (buffer.frame.data[offset] & 0x2000) vfat_data[ichip]->InsertChannel(vfat_rightblock+13); if (buffer.frame.data[offset] & 0x1000) vfat_data[ichip]->InsertChannel(vfat_rightblock+12); if (buffer.frame.data[offset] & 0x0800) vfat_data[ichip]->InsertChannel(vfat_rightblock+11); if (buffer.frame.data[offset] & 0x0400) vfat_data[ichip]->InsertChannel(vfat_rightblock+10); if (buffer.frame.data[offset] & 0x0200) vfat_data[ichip]->InsertChannel(vfat_rightblock+9 ); if (buffer.frame.data[offset] & 0x0100) vfat_data[ichip]->InsertChannel(vfat_rightblock+8 ); if (buffer.frame.data[offset] & 0x0080) vfat_data[ichip]->InsertChannel(vfat_rightblock+7 ); if (buffer.frame.data[offset] & 0x0040) vfat_data[ichip]->InsertChannel(vfat_rightblock+6 ); if (buffer.frame.data[offset] & 0x0020) vfat_data[ichip]->InsertChannel(vfat_rightblock+5 ); if (buffer.frame.data[offset] & 0x0010) vfat_data[ichip]->InsertChannel(vfat_rightblock+4 ); if (buffer.frame.data[offset] & 0x0008) vfat_data[ichip]->InsertChannel(vfat_rightblock+3 ); if (buffer.frame.data[offset] & 0x0004) vfat_data[ichip]->InsertChannel(vfat_rightblock+2 ); if (buffer.frame.data[offset] & 0x0002) vfat_data[ichip]->InsertChannel(vfat_rightblock+1 ); if (buffer.frame.data[offset] & 0x0001) vfat_data[ichip]->InsertChannel(vfat_rightblock+0 ); } } ///////////////////////////////////////////////////////////////////////////////////////// // // VFAT RAW DATA // ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// // // TRACKER & Timing // ///////////////////////////////////////////////////////////////////////////////////////// if ( (ichip>= 0) && (chipdet[ichip]<6) ) { // cout << "TRACKER and Timing "<<"ChipId: " << ichip << " DetId: " << chipdet[ichip] << endl; // I mark this chip as read readcheck[ichip]++; if ( EBV_ChipIdVerbose ) cout << "Chip " << buffer.frame.fullid << " read in event "<< ievent << endl; if (readcheck[ichip] > 1) { cout << "22 Data misalignment error on chip index " << ichip << "\nat file position " << ifile.tellg() << "\nat Chip ID " << buffer.frame.fullid << "\nin detector " <<(*DET[chipdet[ichip]]).DetectorName << "\nTracker Filling" << "\nEvent Number: " << ievent << endl; errorstatus = 10; break; } if (!chipinvert[ichip]) { Int_t lastchanblock = channels_per_chip-16; for(Int_t offset=0; offset < 8; offset++) { //I write explicitely instead of using a for loop, hoping to save some cpu time //offset<<4 is a bit shift of 4 places, that is equivalent to a multiplication by 16 but //it is more cpu time cheap Int_t rightblock = lastchanblock-(offset<<4); if (buffer.frame.data[offset] & 0x8000) g[chipdet[ichip]]->InsertChannel(rightblock+15+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x4000) g[chipdet[ichip]]->InsertChannel(rightblock+14+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x2000) g[chipdet[ichip]]->InsertChannel(rightblock+13+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x1000) g[chipdet[ichip]]->InsertChannel(rightblock+12+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0800) g[chipdet[ichip]]->InsertChannel(rightblock+11+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0400) g[chipdet[ichip]]->InsertChannel(rightblock+10+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0200) g[chipdet[ichip]]->InsertChannel(rightblock+9 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0100) g[chipdet[ichip]]->InsertChannel(rightblock+8 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0080) g[chipdet[ichip]]->InsertChannel(rightblock+7 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0040) g[chipdet[ichip]]->InsertChannel(rightblock+6 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0020) g[chipdet[ichip]]->InsertChannel(rightblock+5 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0010) g[chipdet[ichip]]->InsertChannel(rightblock+4 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0008) g[chipdet[ichip]]->InsertChannel(rightblock+3 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0004) g[chipdet[ichip]]->InsertChannel(rightblock+2 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0002) g[chipdet[ichip]]->InsertChannel(rightblock+1 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0001) g[chipdet[ichip]]->InsertChannel(rightblock+0 + chipoffset[ichip]); } } else { for(Int_t offset=0; offset < 8; offset++) { Int_t rightblock = offset<<4; if (buffer.frame.data[offset] & 0x8000) g[chipdet[ichip]]->InsertChannel(rightblock+0 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x4000) g[chipdet[ichip]]->InsertChannel(rightblock+1 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x2000) g[chipdet[ichip]]->InsertChannel(rightblock+2 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x1000) g[chipdet[ichip]]->InsertChannel(rightblock+3 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0800) g[chipdet[ichip]]->InsertChannel(rightblock+4 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0400) g[chipdet[ichip]]->InsertChannel(rightblock+5 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0200) g[chipdet[ichip]]->InsertChannel(rightblock+6 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0100) g[chipdet[ichip]]->InsertChannel(rightblock+7 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0080) g[chipdet[ichip]]->InsertChannel(rightblock+8 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0040) g[chipdet[ichip]]->InsertChannel(rightblock+9 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0020) g[chipdet[ichip]]->InsertChannel(rightblock+10+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0010) g[chipdet[ichip]]->InsertChannel(rightblock+11+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0008) g[chipdet[ichip]]->InsertChannel(rightblock+12+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0004) g[chipdet[ichip]]->InsertChannel(rightblock+13+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0002) g[chipdet[ichip]]->InsertChannel(rightblock+14+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0001) g[chipdet[ichip]]->InsertChannel(rightblock+15+ chipoffset[ichip]); } } } ///////////////////////////////////////////////////////////////////////////////////////// // // TRACKER // ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// // // CMS Guest // ///////////////////////////////////////////////////////////////////////////////////////// if ( (ichip>=0) && (chipdet[ichip] >= 9) ) { cout << "CMS ChipId: " << ichip << " DetId: " << chipdet[ichip] << endl; // I mark this chip as read readcheck[ichip]++; if ( EBV_ChipIdVerbose ) cout << "Chip " << buffer.frame.fullid << " read in event "<< ievent << endl; if (readcheck[ichip] > 1) { cout << "33 Data misalignment error on chip index " << ichip << "\nat file position " << ifile.tellg() << "\nat Chip ID " << buffer.frame.fullid << "\nin detector " <<(*DET[chipdet[ichip]]).DetectorName << "\nCMS Guest Filling" << "\nEvent Number: " << ievent << endl; errorstatus = 10; break; } cout << "chip index " << ichip << "\nat file position " << ifile.tellg() << "\nat Chip ID " << buffer.frame.fullid << "\nin detector " <<(*DET[chipdet[ichip]]).DetectorName << "\nCMS Guest Filling" << "\nEvent Number: " << ievent << endl; if (!chipinvert[ichip]) { Int_t lastchanblock = channels_per_chip-16; for(Int_t offset=0; offset < 8; offset++) { Int_t rightblock = lastchanblock-(offset<<4); if (buffer.frame.data[offset] & 0x8000) g[chipdet[ichip]]->InsertChannel(rightblock+15+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x4000) g[chipdet[ichip]]->InsertChannel(rightblock+14+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x2000) g[chipdet[ichip]]->InsertChannel(rightblock+13+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x1000) g[chipdet[ichip]]->InsertChannel(rightblock+12+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0800) g[chipdet[ichip]]->InsertChannel(rightblock+11+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0400) g[chipdet[ichip]]->InsertChannel(rightblock+10+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0200) g[chipdet[ichip]]->InsertChannel(rightblock+9 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0100) g[chipdet[ichip]]->InsertChannel(rightblock+8 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0080) g[chipdet[ichip]]->InsertChannel(rightblock+7 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0040) g[chipdet[ichip]]->InsertChannel(rightblock+6 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0020) g[chipdet[ichip]]->InsertChannel(rightblock+5 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0010) g[chipdet[ichip]]->InsertChannel(rightblock+4 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0008) g[chipdet[ichip]]->InsertChannel(rightblock+3 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0004) g[chipdet[ichip]]->InsertChannel(rightblock+2 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0002) g[chipdet[ichip]]->InsertChannel(rightblock+1 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0001) g[chipdet[ichip]]->InsertChannel(rightblock+0 + chipoffset[ichip]); } } else { for(Int_t offset=0; offset < 8; offset++) { Int_t rightblock = offset<<4; if (buffer.frame.data[offset] & 0x8000) g[chipdet[ichip]]->InsertChannel(rightblock+0 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x4000) g[chipdet[ichip]]->InsertChannel(rightblock+1 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x2000) g[chipdet[ichip]]->InsertChannel(rightblock+2 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x1000) g[chipdet[ichip]]->InsertChannel(rightblock+3 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0800) g[chipdet[ichip]]->InsertChannel(rightblock+4 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0400) g[chipdet[ichip]]->InsertChannel(rightblock+5 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0200) g[chipdet[ichip]]->InsertChannel(rightblock+6 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0100) g[chipdet[ichip]]->InsertChannel(rightblock+7 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0080) g[chipdet[ichip]]->InsertChannel(rightblock+8 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0040) g[chipdet[ichip]]->InsertChannel(rightblock+9 + chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0020) g[chipdet[ichip]]->InsertChannel(rightblock+10+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0010) g[chipdet[ichip]]->InsertChannel(rightblock+11+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0008) g[chipdet[ichip]]->InsertChannel(rightblock+12+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0004) g[chipdet[ichip]]->InsertChannel(rightblock+13+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0002) g[chipdet[ichip]]->InsertChannel(rightblock+14+ chipoffset[ichip]); if (buffer.frame.data[offset] & 0x0001) g[chipdet[ichip]]->InsertChannel(rightblock+15+ chipoffset[ichip]); } } cout<<"################## g[chipdet[ichip]] = "<Clear(); if ( ((*g[idet]).nch) > 0 ) { gGeo[idet]->RemoveAllChannels(); //--- Using TClonesArray: Int_t igeocluster = 0; for (Int_t ich = 0; ich < (*g[idet]).nch; ich++) { gGeo[idet]->InsertChannel(TypeOfReadout[idet], (*DET[idet]).OffsetHorizontal, (*DET[idet]).OffsetVertical, (*DET[idet]).FlipHorizontal, (*DET[idet]).FlipVertical, (*g[idet]).ch[ich] ); //--- Using TClonesArray:tmpgeocluster.RemoveAllChannels(); //--- Using TClonesArray:tmpgeocluster.InsertChannel((*g[idet]).ch[ich]); //--- Using TClonesArray:new((*(gGeo[idet]))[igeocluster++]) GeoDataArray(tmpgeocluster); } } //----------------------------------------------------------------------------------------------------------------------------------------------------------- //cout << "End of the Conversion into Spatial Coordinate routine..." << endl; //----------------------------------------------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------------------------------------------- //cout << "Begin of the GeoClusterization routine..." << endl; //----------------------------------------------------------------------------------------------------------------------------------------------------------- gGeoClustVect[idet]->Clear("C"); for (Int_t i=0; iRemoveAllChannels(); geocs = FindGeoCluster( TypeOfReadout[idet], (*DET[idet]).OffsetHorizontal, (*DET[idet]).OffsetVertical, (*DET[idet]).FlipHorizontal, (*DET[idet]).FlipVertical, MaxDistInCluster[idet], PeriodicityInCluster[idet], MaxDistPeriodicityInCluster[idet], *gGeo[idet],geoalreadyused,*geotmpcluster[idet]); //Insert this function into a kind of LookForClusters if (geocs) { geotmpcluster[idet]->UpdatePos(); new ( (*(gGeoClustVect[idet]))[igeocluster++]) GeoCluster(*geotmpcluster[idet]); } } while ( geocs && (igeocluster < MaxNumOfClusters[idet]) ); //----------------------------------------------------------------------------------------------------------------------------------------------------------- //cout << "End of the Clusterization routine..." << endl; //----------------------------------------------------------------------------------------------------------------------------------------------------------- } //if (EBV_Verbose >= 1) cout << "Filling Tree" << endl; tree_raw->Fill(); tree_geo->Fill(); ievent++; if (ievent%100 == 0 && EBV_Verbose==1) cout << "Processing event " << ievent << "\r" << flush; //clear all contents for(Int_t ichip = 0; ichip < chips_per_evt; ichip++) { readcheck[ichip] = 0; } for (Int_t i=0; iRemoveAllChannels(); for (Int_t i=0; iRemoveAllChannels(); //--- Using TClonesArray: for (Int_t i=0; iClear(); for (Int_t i=0; iRemoveAllChannels(); for (Int_t i=0; iClear("C"); for (Int_t i=0; iRemoveAllChannels(); // for (Int_t i=0; iFill(); tree_conf->Write(); tree_raw->Write(); //---Original tree.Write(); tree_geo->Write(); // tree_conf->Print(); // tree_raw->Print(); // tree.Print(); // tree_geo->Print(); TCanvas *c1 = new TCanvas("c1","ROOT Canvas",10,10,1200,600); //cout << "---------------------------------------------------------------------------------" << endl; //cout << "--- BEAM PROFILE AND RELATIVE ALIGNMENT ----------------------------------------" << endl; //cout << "---------------------------------------------------------------------------------" << endl; for (Int_t i=0; iDraw("g1ycl.geoposY:g1xcl.geoposX>>hg1BeamProfile","g1ycl@.GetEntries()==1 && g1xcl@.GetEntries()==1","lego2"); tree_geo->Draw("g1ycl.geoposY:g1xcl.geoposX>>hg1BeamProfile","g1ycl@.GetEntries()==1 && g1xcl@.GetEntries()==1","colz"); hg1BeamProfile->Write(); if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==0) { cout << rawfilename; cout << " g1yBeamMean: "<< hg1BeamProfile->GetMean(2) << " g1yBeamRMS: "<< hg1BeamProfile->GetRMS(2) << " g1xBeamMean: "<< hg1BeamProfile->GetMean(1) << " g1xBeamRMS: "<< hg1BeamProfile->GetRMS(1); } if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==1) { BlueOut("\nTRACKERS BEAM PROFILE DATA ......................................................................\n"); BlueOut("Detector\tYMean\t\tYRMS\t\tXMean\t\tXRMS\t\tDY\t\tDYRMS\t\tDX\t\tDXRMS\t\tENTRIES\n"); printf("g1\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t0.000\t\t0.000\t\t0.000\t\t0.000\t\t%-.0f\n", hg1BeamProfile->GetMean(2) ,hg1BeamProfile->GetRMS(2) ,hg1BeamProfile->GetMean(1) ,hg1BeamProfile->GetRMS(1), hg1BeamProfile->GetEntries()); } break; } } for (Int_t i=0; iDraw("g2ycl.geoposY:g2xcl.geoposX>>hg2BeamProfile","g2ycl@.GetEntries()==1 && g2xcl@.GetEntries()==1","Lego2"); TH2F *hg2BeamProfile = new TH2F("hg2BeamProfile","Beam profile on Tracker 2", 100,0.,100.,100,0.,100.); tree_geo->Draw("g2ycl.geoposY:g2xcl.geoposX>>hg2BeamProfile","g2ycl@.GetEntries()==1 && g2xcl@.GetEntries()==1","colz"); hg2BeamProfile->Write(); TH1F *hg2xoffsetwithg1 = new TH1F("hg2xoffsetwithg1","X Offset of Tracker 2 respect with Tracker 1", 500,-100.,100.); tree_geo->Draw("g2xcl.geoposX-g1xcl.geoposX>>hg2xoffsetwithg1","g2xcl@.GetEntries()==1 && g1xcl@.GetEntries()==1","Lego2"); //hg2xoffsetwithg1->Write(); TH1F *hg2yoffsetwithg1 = new TH1F("hg2yoffsetwithg1","Y Offset of Tracker 2 respect with Tracker 1", 500,-100.,100.); tree_geo->Draw("g2ycl.geoposY-g1ycl.geoposY>>hg2yoffsetwithg1","g2ycl@.GetEntries()==1 && g1ycl@.GetEntries()==1","Lego2"); //hg2yoffsetwithg1->Write(); if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==0) { cout << " g2yBeamMean: "<< hg2BeamProfile->GetMean(2) << " g2yBeamRMS: "<< hg2BeamProfile->GetRMS(2) << " g2xBeamMean: "<< hg2BeamProfile->GetMean(1) << " g2xBeamRMS: "<< hg2BeamProfile->GetRMS(1); cout << " g2-g1yoffset:"<< hg2yoffsetwithg1->GetMean() << " g2-g1yoffsetRMS:"<< hg2yoffsetwithg1->GetRMS() << " g2-g1xoffset:"<< hg2xoffsetwithg1->GetMean() << " g2-g1xoffsetRMS:"<< hg2xoffsetwithg1->GetRMS(); } if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==1) { printf("g2\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.0f\n", hg2BeamProfile->GetMean(2) ,hg2BeamProfile->GetRMS(2) ,hg2BeamProfile->GetMean(1) ,hg2BeamProfile->GetRMS(1), hg2yoffsetwithg1->GetMean() ,hg2yoffsetwithg1->GetRMS() ,hg2xoffsetwithg1->GetMean() ,hg2xoffsetwithg1->GetRMS(), hg2BeamProfile->GetEntries()); } break; } } for (Int_t i=0; iDraw("g3ycl.geoposY:g3xcl.geoposX>>hg3BeamProfile","g3ycl@.GetEntries()==1 && g3xcl@.GetEntries()==1","Lego2"); TH2F *hg3BeamProfile = new TH2F("hg3BeamProfile","Beam profile on Tracker 3", 100,0.,100.,100,0.,100.); tree_geo->Draw("g3ycl.geoposY:g3xcl.geoposX>>hg3BeamProfile","g3ycl@.GetEntries()==1 && g3xcl@.GetEntries()==1","colz"); hg3BeamProfile->Write(); TH1F *hg3xoffsetwithg1 = new TH1F("hg3xoffsetwithg1","X Offset of Tracker 3 respect with Tracker 1", 500,-100.,100.); tree_geo->Draw("g3xcl.geoposX-g1xcl.geoposX>>hg3xoffsetwithg1","g3xcl@.GetEntries()==1 && g1xcl@.GetEntries()==1","Lego2"); //hg3xoffsetwithg1->Write(); TH1F *hg3yoffsetwithg1 = new TH1F("hg3yoffsetwithg1","Y Offset of Tracker 3 respect with Tracker 1", 500,-100.,100.); tree_geo->Draw("g3ycl.geoposY-g1ycl.geoposY>>hg3yoffsetwithg1","g3ycl@.GetEntries()==1 && g1ycl@.GetEntries()==1","Lego2"); //hg3yoffsetwithg1->Write(); if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==0) { cout << " g3yBeamMean: "<< hg3BeamProfile->GetMean(2) << " g3yBeamRMS: "<< hg3BeamProfile->GetRMS(2) << " g3xBeamMean: "<< hg3BeamProfile->GetMean(1) << " g3xBeamRMS: "<< hg3BeamProfile->GetRMS(1); cout << " g3-g1yoffset:"<< hg3yoffsetwithg1->GetMean() << " g3-g1yoffsetRMS:"<< hg3yoffsetwithg1->GetRMS() << " g3-g1xoffset:"<< hg3xoffsetwithg1->GetMean() << " g3-g1xoffsetRMS:"<< hg3xoffsetwithg1->GetRMS(); } if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==1) { printf("g3\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.0f\n", hg3BeamProfile->GetMean(2) ,hg3BeamProfile->GetRMS(2) ,hg3BeamProfile->GetMean(1) ,hg3BeamProfile->GetRMS(1), hg3yoffsetwithg1->GetMean() ,hg3yoffsetwithg1->GetRMS() ,hg3xoffsetwithg1->GetMean() ,hg3xoffsetwithg1->GetRMS(), hg3BeamProfile->GetEntries()); } break; } } for (Int_t i=0; iDraw("g4ycl.geoposY:g4xcl.geoposX>>hg4BeamProfile","g4ycl@.GetEntries()==1 && g4xcl@.GetEntries()==1","Lego2"); hg4BeamProfile->Write(); TH1F *hg4xoffsetwithg1 = new TH1F("hg4xoffsetwithg1","X Offset of Tracker 4 respect with Tracker 1", 500,-100.,100.); tree_geo->Draw("g4xcl.geoposX-g1xcl.geoposX>>hg4xoffsetwithg1","g4xcl@.GetEntries()==1 && g1xcl@.GetEntries()==1","Lego2"); //hg4xoffsetwithg1->Write(); TH1F *hg4yoffsetwithg1 = new TH1F("hg4yoffsetwithg1","Y Offset of Tracker 4 respect with Tracker 1", 500,-100.,100.); tree_geo->Draw("g4ycl.geoposY-g1ycl.geoposY>>hg4yoffsetwithg1","g4ycl@.GetEntries()==1 && g1ycl@.GetEntries()==1","Lego2"); //hg4yoffsetwithg1->Write(); if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==0) { cout << " g4yBeamMean: "<< hg4BeamProfile->GetMean(2) << " g4yBeamRMS: "<< hg4BeamProfile->GetRMS(2) << " g4xBeamMean: "<< hg4BeamProfile->GetMean(1) << " g4xBeamRMS: "<< hg4BeamProfile->GetRMS(1); cout << " g4-g1yoffset:"<< hg4yoffsetwithg1->GetMean() << " g4-g1yoffsetRMS:"<< hg4yoffsetwithg1->GetRMS() << " g4-g1xoffset:"<< hg4xoffsetwithg1->GetMean() << " g4-g1xoffsetRMS:"<< hg4xoffsetwithg1->GetRMS(); } if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==1) { printf("g4\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.0f\n", hg4BeamProfile->GetMean(2) ,hg4BeamProfile->GetRMS(2) ,hg4BeamProfile->GetMean(1) ,hg4BeamProfile->GetRMS(1), hg4yoffsetwithg1->GetMean() ,hg4yoffsetwithg1->GetRMS() ,hg4xoffsetwithg1->GetMean() ,hg4xoffsetwithg1->GetRMS(), hg4BeamProfile->GetEntries()); BlueOut(".................................................................................................\n\n"); } break; } } //--- XLoop on the declared detectors ------------------------------------------------------------------------------------------------- TString xref; bool xdet_exist; Float_t xdet_xcoord_mean=0., xdet_xcoord_rms=0., xmeanoff=999., xrmsoff=999.; Int_t xentriesoff=0; TString xdet, xdet_xcoord, xdet_xcoord_name, hxdet_name, hxdet_title, hxdet_draw, hx_cut; Int_t xrefid=0; if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==1) { BlueOut("\nDetector XOffset DATA ......................................................................\n"); BlueOut("Entries\t\tXMean\t\tXRMS\t\tDX\t\tDXRMS\t\tDetector\n"); } for (Int_t i=0; i> hxcoordtmp"; tree_geo->Draw(xdet_xcoord_name); xdet_xcoord_mean = hxcoordtmp->GetMean(); xdet_xcoord_rms = hxcoordtmp->GetRMS(); if (xdet_xcoord_rms!=0 && xdet_xcoord_mean!=999) {xdet_exist = 1;} else {xdet_exist = 0;}; if (xdet_exist) { hxdet_name = "hXOffset_" + xdet + "_" + xref; hxdet_title= "X Offset of " + xdet + " respect with " + xref; hxdet_draw = xdet + ".geoposX"+"-"+ xref + ".geoposX" + ">>" + hxdet_name; hx_cut = xref + "@.GetEntries()==1" + " && " + xdet + "@.GetEntries()==1"; char hxdet[hxdet_name.Length()]; sprintf(hxdet,"%s",(const char *)hxdet_name); TH1F *hxdetPtr; hxdetPtr=(TH1F*)hxdet; tree_geo->Draw(xdet_xcoord_name, hx_cut); xdet_xcoord_mean = hxcoordtmp->GetMean(); xdet_xcoord_rms = hxcoordtmp->GetRMS(); hxdetPtr = new TH1F(hxdet_name, hxdet_title, 500,-100.,100.); tree_geo->Draw(hxdet_draw, hx_cut); xmeanoff = hxdetPtr->GetMean(); xrmsoff = hxdetPtr->GetRMS(); xentriesoff = hxdetPtr->GetEntries(); hxdetPtr->Write(); delete hxdetPtr; } delete hxcoordtmp; /* if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==0) { cout << " g4yBeamMean: "<< hg4BeamProfile->GetMean(2) << " g4yBeamRMS: "<< hg4BeamProfile->GetRMS(2) << " g4xBeamMean: "<< hg4BeamProfile->GetMean(1) << " g4xBeamRMS: "<< hg4BeamProfile->GetRMS(1); cout << " g4-g1yoffset:"<< hg4yoffsetwithg1->GetMean() << " g4-g1yoffsetRMS:"<< hg4yoffsetwithg1->GetRMS() << " g4-g1xoffset:"<< hg4xoffsetwithg1->GetMean() << " g4-g1xoffsetRMS:"<< hg4xoffsetwithg1->GetRMS(); } */ if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==1) { if (xentriesoff>0) printf("%d\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%s\n", xentriesoff, xdet_xcoord_mean, xdet_xcoord_rms, xmeanoff, xrmsoff,(const char*)(*DET[i]).DetectorName); } } if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==1) { BlueOut(".................................................................................................\n\n"); } //--- XLoop on the declared detectors ------------------------------------------------------------------------------------------------- //--- YLoop on the declared detectors ------------------------------------------------------------------------------------------------- TString yref; bool ydet_exist; Float_t ydet_ycoord_mean=0., ydet_ycoord_rms=0., ymeanoff=999., yrmsoff=999.; Int_t yentriesoff=0; TString ydet, ydet_ycoord, ydet_ycoord_name, hydet_name, hydet_title, hydet_draw, hy_cut; Int_t yrefid=1; if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==1) { BlueOut("\nDetector YOffset DATA ......................................................................\n"); BlueOut("Entries\t\tYMean\t\tYRMS\t\tDY\t\tDYRMS\t\tDetector\n"); } for (Int_t i=0; i> hycoordtmp"; tree_geo->Draw(ydet_ycoord_name); ydet_ycoord_mean = hycoordtmp->GetMean(); ydet_ycoord_rms = hycoordtmp->GetRMS(); if (ydet_ycoord_rms!=0 && ydet_ycoord_mean!=999) {ydet_exist = 1;} else {ydet_exist = 0;}; if (ydet_exist) { ydet = (*DET[i]).DetectorName; hydet_name = "hYOffset_" + ydet + "_" + yref; hydet_title= "Y Offset of " + ydet + " respect with " + yref; hydet_draw = ydet + ".geoposY"+"-"+ yref + ".geoposY" + ">>" + hydet_name; hy_cut = yref + "@.GetEntries()==1" + " && " + ydet + "@.GetEntries()==1"; char hydet[hydet_name.Length()]; sprintf(hydet,"%s",(const char *)hydet_name); TH1F *hydetPtr; hydetPtr=(TH1F*)hydet; tree_geo->Draw(ydet_ycoord_name,hy_cut); ydet_ycoord_mean = hycoordtmp->GetMean(); ydet_ycoord_rms = hycoordtmp->GetRMS(); hydetPtr = new TH1F(hydet_name, hydet_title, 500,-100.,100.); tree_geo->Draw(hydet_draw, hy_cut); ymeanoff = hydetPtr->GetMean(); yrmsoff = hydetPtr->GetRMS(); yentriesoff = hydetPtr->GetEntries(); hydetPtr->Write(); delete hydetPtr; } delete hycoordtmp; /* if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==0) { cout << " g4yBeamMean: "<< hg4BeamProfile->GetMean(2) << " g4yBeamRMS: "<< hg4BeamProfile->GetRMS(2) << " g4xBeamMean: "<< hg4BeamProfile->GetMean(1) << " g4xBeamRMS: "<< hg4BeamProfile->GetRMS(1); cout << " g4-g1yoffset:"<< hg4yoffsetwithg1->GetMean() << " g4-g1yoffsetRMS:"<< hg4yoffsetwithg1->GetRMS() << " g4-g1xoffset:"<< hg4xoffsetwithg1->GetMean() << " g4-g1xoffsetRMS:"<< hg4xoffsetwithg1->GetRMS(); } */ if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==1) { if (yentriesoff>0) printf("%d\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%-.3f\t\t%s\n", yentriesoff, ydet_ycoord_mean, ydet_ycoord_rms, ymeanoff, yrmsoff,(const char*)(*DET[i]).DetectorName); } } if (EBV_BeampProfiledataPrintOut==1 && EBV_Verbose==1) { BlueOut(".................................................................................................\n\n"); } //--- XLoop on the declared detectors ------------------------------------------------------------------------------------------------- cout << endl; //cout << "---------------------------------------------------------------------------------" << endl; //cout << "--- END OF BEAM PROFILE AND RELATIVE ALIGNMENT ---------------------------------" << endl; //cout << "---------------------------------------------------------------------------------" << endl; if (EBV_EfficiencyEstimatorPrintOut){ //cout << "---------------------------------------------------------------------------------" << endl; //cout << "--- EFFICIENCIES ESTIMATION ---------------------------------------------------" << endl; //cout << "---------------------------------------------------------------------------------" << endl; TCut g1SingleHit("g1SingleHit","g1ycl@.GetEntries()==1 && g1xcl@.GetEntries()==1"); TCut g2SingleHit("g2SingleHit","g2ycl@.GetEntries()==1 && g2xcl@.GetEntries()==1"); TCut g3SingleHit("g3SingleHit","g3ycl@.GetEntries()==1 && g3xcl@.GetEntries()==1"); TCut g4SingleHit("g4SingleHit","g4ycl@.GetEntries()==1 && g4xcl@.GetEntries()==1"); TCut g1g2Algnd("g1g2Algnd","TMath::Abs(g1xcl.geoposX-g2xcl.geoposX)<4 && TMath::Abs(g1ycl.geoposY-g2ycl.geoposY)<4"); TCut g1g3Algnd("g1g3Algnd","TMath::Abs(g1xcl.geoposX-g3xcl.geoposX)<4 && TMath::Abs(g1ycl.geoposY-g3ycl.geoposY)<4"); TCut g2g3Algnd("g2g3Algnd","TMath::Abs(g2xcl.geoposX-g3xcl.geoposX)<4 && TMath::Abs(g2ycl.geoposY-g3ycl.geoposY)<4"); TCut CTLMiddleArea("CTLMiddleArea","g2xcl.geoposX>50 && g2xcl.geoposX<75 && g2ycl.geoposY>60 && g2ycl.geoposY<90"); TCut CTLBottomLeftArea("CTLMiddleLeftArea","g2xcl.geoposX>22 && g2xcl.geoposX<44 && g2ycl.geoposY>32 && g2ycl.geoposY<54"); //TCut g1T2StripsAligned("g1T2Strips","TMath::Abs(g1T2Padscl.geoposR-g1T2Stripscl.geoposR)<10"); //TCut g2T2StripsAligned("g2T2Strips","TMath::Abs(g2T2Padscl.geoposR-g2T2Stripscl.geoposR)<10"); Float_t g1T2Pads_Eff , g1T2Pads_EffErr , g1T2Pads_Sample , g1T2Pads_True ; Float_t g1T2Strips_Eff , g1T2Strips_EffErr, g1T2Strips_Sample, g1T2Strips_True ; Float_t g2T2Pads_Eff , g2T2Pads_EffErr , g2T2Pads_Sample , g2T2Pads_True ; Float_t g2T2Strips_Eff , g2T2Strips_EffErr, g2T2Strips_Sample, g2T2Strips_True ; Float_t gCTLMiddleLeft_Eff, gCTLMiddleLeft_EffErr, gCTLMiddleLeft_Sample, gCTLMiddleLeft_True; Float_t gCTLTopMiddle_Eff, gCTLTopMiddle_EffErr, gCTLTopMiddle_Sample, gCTLTopMiddle_True; Float_t gCTLBottomLeftY_Eff, gCTLBottomLeftX_EffErr, gCTLBottomLeftX_Sample, gCTLBottomLeftX_True; Float_t gCTLBottomLeftX_Eff, gCTLBottomLeftY_EffErr, gCTLBottomLeftY_Sample, gCTLBottomLeftY_True; gCTLMiddleLeft_True =(Float_t)(tree_geo->Project("htmp","g2ycl.geoposY:g2xcl.geoposX",g1SingleHit && g2SingleHit && g1g2Algnd && CTLMiddleArea )); gCTLTopMiddle_True =(Float_t)(tree_geo->Project("htmp","g2ycl.geoposY:g2xcl.geoposX",g1SingleHit && g2SingleHit && g1g2Algnd && CTLMiddleArea )); gCTLBottomLeftY_True =(Float_t)(tree_geo->Project("htmp","g2ycl.geoposY:g2xcl.geoposX",g1SingleHit && g2SingleHit && g1g2Algnd && CTLBottomLeftArea )); gCTLBottomLeftX_True =(Float_t)(tree_geo->Project("htmp","g2ycl.geoposY:g2xcl.geoposX",g1SingleHit && g2SingleHit && g1g2Algnd && CTLBottomLeftArea )); gCTLMiddleLeft_Sample =(Float_t)(tree_geo->Project("htmp","g2ycl.geoposY:g2xcl.geoposX",g1SingleHit && g2SingleHit && g1g2Algnd && CTLMiddleArea)); gCTLTopMiddle_Sample =(Float_t)(tree_geo->Project("htmp","g2ycl.geoposY:g2xcl.geoposX",g1SingleHit && g2SingleHit && g1g2Algnd && CTLMiddleArea)); gCTLBottomLeftY_Sample =(Float_t)(tree_geo->Project("htmp","g2ycl.geoposY:g2xcl.geoposX",g1SingleHit && g2SingleHit && g1g2Algnd && CTLBottomLeftArea)); gCTLBottomLeftX_Sample =(Float_t)(tree_geo->Project("htmp","g2ycl.geoposY:g2xcl.geoposX",g1SingleHit && g2SingleHit && g1g2Algnd && CTLBottomLeftArea)); gCTLMiddleLeft_Eff =gCTLMiddleLeft_True/gCTLMiddleLeft_Sample; gCTLTopMiddle_Eff =gCTLTopMiddle_True/gCTLTopMiddle_Sample; gCTLBottomLeftY_Eff =gCTLBottomLeftX_True/gCTLBottomLeftX_Sample; gCTLBottomLeftX_Eff =gCTLBottomLeftY_True/gCTLBottomLeftY_Sample; gCTLMiddleLeft_EffErr =TMath::Sqrt(gCTLMiddleLeft_Eff*(1-gCTLMiddleLeft_Eff)/gCTLMiddleLeft_Sample); gCTLTopMiddle_EffErr =TMath::Sqrt(gCTLTopMiddle_Eff*(1-gCTLTopMiddle_Eff)/gCTLTopMiddle_Sample); gCTLBottomLeftY_EffErr =TMath::Sqrt(gCTLBottomLeftX_Eff*(1-gCTLBottomLeftX_Eff)/(gCTLBottomLeftX_Sample)); gCTLBottomLeftX_EffErr =TMath::Sqrt(gCTLBottomLeftY_Eff*(1-gCTLBottomLeftY_Eff)/(gCTLBottomLeftY_Sample)); if (EBV_EfficiencyEstimatorPrintOut==1 && EBV_Verbose==0){ cout << "FileName "<< "g1T2Pads_Eff " <<"g1T2Pads_EffErr " <<"g1T2Pads_Sample " << "g1T2Strips_Eff " <<"g1T2Strips_EffErr " <<"g1T2Strips_Sample " << "g2T2Pads_Eff " <<"g2T2Pads_EffErr " <<"g2T2Pads_Sample " << "g2T2Strips_Eff " <<"g2T2Strips_EffErr " <<"g2T2Strips_Sample " << "gCTLMiddleLeft_Eff " <<"gCTLMiddleLeft_EffErr " <<"gCTLMiddleLeft_Sample " << "gCTLTopMiddle_Eff " <<"gCTLTopMiddle_EffErr " <<"gCTLTopMiddle_Sample " << "gCTLBottomLeftY_Eff " <<"gCTLBottomLeftX_EffErr " <<"gCTLBottomLeftX_Sample " << "gCTLBottomLeftX_Eff " <<"gCTLBottomLeftY_EffErr " <<"gCTLBottomLeftY_Sample " << endl; cout << rawfilename <<" "<< gCTLMiddleLeft_Eff <<" "<Close(); /* for (Int_t i=0; iDelete() ; break; } } for (Int_t i=0; iDelete() ; hg2xoffsetwithg1->Delete() ; hg2yoffsetwithg1->Delete() ; break; } } for (Int_t i=0; iDelete() ; hg3xoffsetwithg1->Delete() ; hg3yoffsetwithg1->Delete() ; break; } } for (Int_t i=0; iDelete() ; hg4xoffsetwithg1->Delete() ; hg4yoffsetwithg1->Delete() ; break; } } */ if (EBV_Verbose==1) { YellowOut("\nTrees written on file and file closed.To access it:\n\n1. From ROOT:\n"); cout << "TFile file0(\"" << rootfilename << "\"); file0.ls();" << endl; YellowOut("2. From Shell:\n"); cout << "root -l " << rootfilename <<"\n"<