// // First we need to "forward declare" some of the classes // which we will be using. This let's us setup pointers // to them before root has actually loaded their definitions. // class TChain; // Root "chains" class EEfeeRawEvent; // EEMC raw events class EEmcEventHeader; // EEMC event headers class EEstarTrig; // Start trigger information class EEmcGeomSimple; // EEMC tower geometry class EEmcSmdGeom; // EEMC SMD Geometry class EEmcSmdMap; // Matching of SMD strips to towers class EEmcDb; // EEMC database class EEezAnalysis; // EEMC event analyser class EEezClAnalysis; // EEMC cluster finder class EEsmdProfile; // EEMC smd profiler class EEezTower; // tower description class class EEezClusterQA; // cluster histograms class EEsmdIsoClusters; // EEMC smd isolation class EEmcIsoSmdCal; // EEMC smd calibration using isolated clusters TChain *ezchain; EEfeeRawEvent *eFee; EEmcEventHeader *eHead; EEstarTrig *eTrig; EEmcDb *database; EEmcGeomSimple *eeGeom; EEmcSmdMap *smdMap; EEmcSmdGeom *smdGeom; EEezAnalysis *mEEanalysis; EEezClAnalysis *mEEclusters; EEsmdProfile *mEEprofiles; EEezClusterQA *mEEclusterQA; EEezClusterQA *mEEisoClusterQA; EEsmdIsoClusters *mEEisoClusters; EEmcIsoSmdCal *mESMDcal; Long_t timeStamp; // timestamp of the first event Int_t currentEvent = 0; // current entry in TTree (TChain) Int_t rhic_year = 5; Int_t firstEvent = 0; // by default start from 0th event // // This is a list of dynamic libraries needed by the // analysis. You can add additional libraries here // as needed, and they will be loaded by the loadLibs() // function. Just add more libraries as you need them. // Char_t *libraries[] = { "StRoot/StDbLib/StDbLib.so", "StRoot/StEEmcDbMaker/libEEmcDbMaker.so", "StRoot/StEEmcUtil/EEfeeRaw/libEEfeeRaw.so", "StRoot/StEEmcUtil/EEmcSmdMap/libEEmcSmdMap.so", "StRoot/StEEmcUtil/EEmcGeom/libEEmcGeom.so", "StRoot/StEEmcUtil/StEEmcSmd/libEEmcSmdGeom", "EEmcDb/libEEmcDb.so", "libPhysics", "EEezAnalysis/libEEezAnalysis.so" }; Int_t verbose = 1; Int_t minSector = 1; Int_t maxSector = 12; Int_t nevents = 0; TFile *file; ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// void ezSmdCalII ( Int_t maxEvents = 400000, Char_t *myRunList = "R5088003 R5088020 R5088040 R5088054 R5088067 R5088017 R5088033 R5088052 R5088056 R5072020 R5072023 R5072067 R5073007 ", Int_t firstSec = 4, Int_t lastSec = 9, Char_t *treePath="processall/", Char_t *dbflavor = "onlped", Int_t myverbose = 0 ) { //-- Load shared libraries loadLibs(); //-- Chain the data Chain(myRunList,treePath); //-- Initialize geometry classes Init(); //-- Initialize the database minSector = firstSec; maxSector = lastSec; Database ( dbflavor ); //database -> readAsciiDataBase("eemc-database-smd-qa.dat",minSector,maxSector); database -> readAsciiDataBase("newgains.dat",minSector,maxSector); //-- Initialize the cluster finder InitClusterFinder(); TFile *cal = new TFile("esmdcal.hist.root","RECREATE"); cal -> cd(); mESMDcal = new EEmcIsoSmdCal("mESMDcal"); mESMDcal -> Init(); cal -> cd(".."); //-- //-- Event loop //-- Int_t lastEvent = maxEvents; for ( Int_t event = firstEvent; event <= lastEvent; event++ ) { // Get the data from this event ezchain -> GetEntry(event); assert(eFee); // Mask out bad crates if ( rhic_year >= 5 ) eFee -> maskWrongCrates(timeStamp,eHead->getToken()); // Process the data from this event processEvent(); std::cout << " N event = " << event << std::endl; // Clear all analysis "makers" clearAll(); } mESMDcal -> RemakeGains(7,database); database -> exportAscii("newgains.dat"); file -> Write(); cal -> Write(); } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// void processEvent() { mEEanalysis -> Make ( eFee ); mEEclusters -> Make ( mEEanalysis ); mEEprofiles -> Make ( mEEclusters, eHead ); mEEisoClusters -> Make(); Int_t nc = mEEclusters -> getNClusters(); for ( Int_t i = 0; i < nc; i++ ) { mEEclusterQA -> Fill ( mEEclusters -> getClusterPtr(i) ); } nc = mEEisoClusters -> getNClusters(); for ( Int_t i = 0; i < nc; i++ ) { EEezCluster *cluster = mEEisoClusters -> getClusterPtr(i); mEEisoClusterQA -> Fill ( cluster ); if ( cluster -> getSeedTower() -> getSector() == 6 ) mESMDcal -> Fill ( cluster ); } } void clearAll() { mEEanalysis -> Clear(); mEEclusters -> Clear(); mEEprofiles -> Clear(); mEEisoClusters -> Clear(); } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// void loadLibs() { std::cout << "--" << std::endl << "-- Loading shared libraries" << std::endl << "--" << std::endl; for ( Int_t i = 0; i < sizeof(libraries)/sizeof(Char_t*); i++ ) { if ( verbose ) std::cout << "Loading " << libraries[i]; assert(!gSystem -> Load( libraries[i] )); if ( verbose ) std::cout << "... success" << std::endl; } std::cout << std::endl; } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// void Chain( Char_t *runList, Char_t *treePath ) { std::cout << "--" << std::endl << "-- Chaining ezTree files in runlist" << std::endl << "--" << std::endl; TString ezTreePath = treePath; // Setup the datafile for input ezchain = new TChain("ezstar"); int i=0; char *run=strtok(runList," "); // init 'strtok' do { TString fullName=ezTreePath+run+".ez.root"; printf("add run %d '%s' %s\n",i++,run,fullName.Data()); // TString fullName=ezTreePath+run+".ez.root"; ezchain->Add(fullName); } while(run=strtok(0," ")); // advance by one nam // EEfeeRawEvent *eFee=0; // EEmcEventHeader *eHead =0; eFee = NULL; eHead = NULL; eTrig = NULL; ezchain->SetBranchAddress("eemc",&eFee); ezchain->SetBranchAddress("head",&eHead); ezchain->SetBranchAddress("trig",&eTrig); ezchain->GetEntry(0);// read first event nevents = TMath::Min( nevents, ezchain -> GetEntries() ); std::cout << "--" << std::endl << "-- chain has " << ezchain -> GetEntries() << " " << "processing " << nevents << std::endl << "--" << std::endl; } ///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////. void Init() { smdMap = EEmcSmdMap::instance(); smdGeom = EEmcSmdGeom::instance(); eeGeom = new EEmcGeomSimple(); } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// void Database( Char_t *dbflavor, Char_t *dbfile = "NONE" ) { std::cout << "--" << std::endl << "-- Initializing EEMC Database" << std::endl << "--" << std::endl; timeStamp=eHead->getTimeStamp(); printf("run timeStamp=%d=%s\n" ,timeStamp,ctime((const time_t *)&timeStamp)); //............ DB-reader ................. database = new EEmcDb() ; // Set the threshold in the database database -> setThreshold(5.0); // Load in a specified flavor if ( dbflavor != "NONE" && dbfile == "NONE" ) database->setPreferredFlavor( dbflavor,"eemcPMTped"); // Query the database for the specified timestamp if ( dbfile == "NONE" ) database->requestDataBase(timeStamp,minSector,maxSector); // Load in a specified file, if given, to overwrite // the database requested above if ( dbfile != "NONE" ) database -> readAsciiDataBase ( dbfile, minSector, maxSector ); } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// void InitClusterFinder() { //-- Ready the cluster finder mEEanalysis = new EEezAnalysis(); mEEanalysis -> setDb ( database ); mEEanalysis -> setSeedEnergy(0.7); mEEanalysis -> Init(); mEEclusters = new EEezClAnalysis(); mEEclusters -> setShapeLimit(0.75); mEEclusters -> Init(); mEEprofiles = new EEsmdProfile("smdProfiles"); mEEprofiles -> Init(); mEEisoClusters = new EEsmdIsoClusters("smdIsoClusters"); mEEisoClusters -> Init(); mEEisoClusters -> setAnalysis ( mEEanalysis ); mEEisoClusters -> setClusterFinder ( mEEclusters ); file = new TFile("clusterqa.hist.root","RECREATE"); file -> cd(); mEEclusterQA = new EEezClusterQA("allClusters"); mEEclusterQA -> Init(); mEEclusterQA -> setAnalysis ( mEEanalysis ); mEEclusterQA -> setSmdProfiler ( mEEprofiles ); mEEisoClusterQA = new EEezClusterQA("isolatedClusters"); mEEisoClusterQA -> Init(); mEEisoClusterQA -> setAnalysis ( mEEanalysis ); mEEisoClusterQA -> setSmdProfiler ( mEEprofiles ); file -> cd(".."); }