#define pisaMAIN #include "pisaReco.h" #include "precoSelect.h" #include "recoConsts.h" #include "nodestuff.h" #include "timestampstuff.h" #include "bbcfuncs.h" #include "mvdfuncs.h" #include "vtxfuncs.h" #include "dchfuncs.h" #include "padfuncs.h" #include "crkfuncs.h" #include "tecfuncs.h" #include "toffuncs.h" #include "emcfuncs.h" #include "cglfuncs.h" #include "momfuncs.h" #include "muifuncs.h" #include "dispfuncs.h" #include "ertfuncs.h" int pisaFileOpen(char* pisaInputFile) { pisaFile = new TFile(pisaInputFile); treePisa = (TTree*)pisaFile->Get("T"); pisaRun = new PISARun(); pisaEvent = new PISAEvent(); branchPisa = treePisa->GetBranch("pisaevent"); branchPisa->SetAddress(&pisaEvent); TTArray[0] = treePisa; pisaEventArray[0] = pisaEvent; /* // // Read first event to pick up run information (THIS PRODUCES TRTRNO ERRORS ??) // pisaRun->GetOneEvent(pisaEvent,&kPisaEvent,treePisa); kPisaEvent = 0; // reset to 0 for event processing PISAEventHeader *pisaEventHeader = PISAEventHeader::GetEventHeader(); pisaRunNumber = pisaEventHeader->GetIDRun(); cout << "\n pisaFileOpen : Run number on PISA hits file = " << pisaRunNumber << endl; */ return 0; } int pisaSetMergeFiles(int mergeFiles) { if(mergeFiles<0 || mergeFiles>=PISAMAXFILES) { cerr << "\n pisaSetMergeFiles : mergeFiles = " << mergeFiles << " is not allowed." << endl; cerr << " Minimum mergeFiles value is 0, maximum mergeFiles value is " << PISAMAXFILES - 1 << endl; exit(2); } nFiles = mergeFiles + 1; } int pisaMergeFileOpen(char* pisaInputFile, int kFile) { if(kFile<1 || kFile>=nFiles) { cerr << "\n pisaMergeFileOpen : kFile = " << kFile << " is not allowed." << endl; cerr << " Minimum kFile value is 1, maximum kFile value is " << nFiles-1 << endl; exit(3); } pisaFileArray[kFile] = new TFile(pisaInputFile); if(!pisaFileArray[kFile]) { cerr << "\n pisaMergeFileOpen : new TFile fails for pisaInputFile = " << pisaInputFile << endl; exit(4); } TTArray[kFile] = (TTree*)pisaFileArray[kFile]->Get("T"); if(!pisaFileArray[kFile]) { cerr << "\n pisaMergeFileOpen : Get(T) fails for pisaInputFile = " << pisaInputFile << endl; exit(5); } pisaEventArray[kFile] = new PISAEvent(); branchPisaArray[kFile] = TTArray[kFile]->GetBranch("pisaevent"); branchPisaArray[kFile]->SetAddress(&pisaEventArray[kFile]); cout << "\n pisaMergFileOpen : Opened PISA hits file " << pisaInputFile << " as Merge File #" << kFile << endl; return 0; } void setSimFileDBFlag(int fileDBFlag) { // // simFileDBFlag request by the EMCal group for using in event reconstruction // simFileDBFlag is set to a real run number matching the detector conditions stored in Objy // simFileDBFlag = fileDBFlag; if(simFileDBFlag > 0) { cout << "\n setSimFileDBFlag : simFileDBFlag set to real run number " << simFileDBFlag << endl; } return; } int getSimFileDBFlag() { if(simFileDBFlag > 0) { cout << "\n simFileDBFlag has been set to real number " << simFileDBFlag << endl; } else { cout << "\n simFileDBFlag is not set " << endl; } return simFileDBFlag; } int simSetRunNumber(int runNumb) { runNumber = runNumb; cout << "\n simSetRunNumber : Re-setting run number to " << runNumber << endl; return 0; } int simDstFileOpen(char* simDstOutputFile) { PHString dstOutFile = simDstOutputFile; simDstOut = new PHNodeIOManager(dstOutFile,PHWrite); return 0; } int prdfFileOpen(char* prdfOutputFile, int runNumb) { PHString prdfOutFile = prdfOutputFile; cout << "\n Output PRDF name = " << prdfOutFile; cout << ", using Run Number " << runNumb<< endl; prdfOut = new PHRawOManager(prdfOutFile,runNumb,8*1024*1024/4); runNumber = runNumb; return 0; } int parFileOpen(char* parOutputFile) { PHString parOutFile = parOutputFile; parOut = new PHNodeIOManager(parOutFile,PHWrite); return 0; } int relFileOpen(char* relOutputFile) { PHString relOutFile = relOutputFile; relOut = new PHNodeIOManager(relOutFile,PHWrite); if(relOut->SetCompressionLevel(1)) cout << "\n GEANT Association Tables file compression level set to 1" << endl; else cout << "\n GEANT Association Tables file is not compressed" << endl; return 0; } int pisaNodesInit() { year1Flag = 0; // accounts for On-Line changes from Run1 to Run2 setup_all(); // sets up the PHOOL node structure size_t mr=30000; fkinWrapper* fkin = new fkinWrapper("fkin",mr); PHIODataNode* fkinNode = new PHIODataNode(fkin,"fkin"); evaNode->addNode(fkinNode); primaryWrapper* primary = new primaryWrapper("primary",mr); PHIODataNode* primaryNode = new PHIODataNode(primary,"primary"); evaNode->addNode(primaryNode); pythiaWrapper* pythia = new pythiaWrapper("pythia",mr); PHIODataNode* pythiaNode = new PHIODataNode(pythia,"pythia"); evaNode->addNode(pythiaNode); mr=10; headerWrapper* header = new headerWrapper("header",mr); PHIODataNode* headerNode = new PHIODataNode(header,"header"); evaNode->addNode(headerNode); /* prdfNode = new PHCompositeNode("PRDF"); topNode->addNode(prdfNode); */ return 0; } int pisaFileRun(int maxEvents) { // // This was what was in camTaskIni.C and camrespini.C // //TimeStamp = PHTimeStamp(2000,4,5,0,0,0); // // Above causes a crash in crk_setup // // // Following code works for only single event file input (not Merge) // Int_t trueEvents = Int_t(treePisa->GetEntries()); Int_t readEvents = maxEvents; if(maxEvents == -1) readEvents = trueEvents; if(trueEvents < readEvents) { readEvents = trueEvents; cout << "\n pisaFileRun : number of events requested = " << maxEvents; cout << "\n Number of events in this file is only " << trueEvents << endl; } cout << "\n pisaFileRun : number of events to be processed = " << readEvents; // // Change to MERGE Events method of getting the event (better debugged in the past) // // // safety check for Merge Files // for(int kFiles=0; kFiles: input file count failure at kFiles = " << kFiles; cerr << ", TTArray[kFiles] = " << TTArray[kFiles]; cerr << ", pisaEventArray[kFiles] " << pisaEventArray[kFiles]; cerr << endl; exit(6); } // safety check that all the Merge Files were given as input } for(int iEvent=0; iEventGetOneEvent(pisaEventArray, &kPisaEvent, TTArray, nFiles); // taking nFiles for input if (iEvent==0){ pisaNodesInit(); cout << "\n PISA nodes initialization finished" << endl; } // check if this is the first event KinGetGEA(topNode); if(simVertexFlag == 0) { if(precoSelect::isBBC()) { BbcGetGEA(topNode); ana_bbc(); cout << "\n ana_bbc finished" << endl; } if(precoSelect::isMVD()) { MvdGetGEA(topNode); ana_mvd(); cout << "\n ana_mvd finished" << endl; } } else { simSetBbcOut(); // set the BBC Z0 to simVertex value, BBC T0 to 0.0 } // check on simVertexFlag, used for single particle studies in simulation if(precoSelect::isPAD()) { PadGetGEA(topNode); ana_pad(); cout << "\n ana_pad finished" << endl; } if (simulationFlag == 2 && precoSelect::isVTX()) { ana_vtx(); cout << "\n pisaReco.C : finished ana_vtx" << endl; } // VTX cannot be called unless in PISA-to-DST mode if(precoSelect::isDCH()) { DchGetGEA(topNode); ana_dch(); cout << "\n ana_dch finished" << endl; } if(precoSelect::isCRK()) { CrkGetGEA(topNode); ana_crk(); cout << "\n ana_crk finished" << endl; } if(precoSelect::isTEC()) { TecGetGEA(topNode); ana_tec(); cout << "\n ana_tec finished" << endl; } if(precoSelect::isTOF()) { TofGetGEA(topNode); ana_tof(); cout << "\n ana_tof finished" << endl; } if(precoSelect::isEMC()) { EmcGetGEA(topNode); ana_emc(); cout << "\n ana_emc finished" << endl; } if (precoSelect::isCGL()) { ana_cgl(); cout << "\n ana_cgl finished" << endl; } if (precoSelect::isMOM()) { ana_mom(); cout << "\n ana_mom finished" << endl; } if (precoSelect::isERT()) { ana_ert(); cout << "\n ana_ert finished" << endl; } if (precoSelect::isTEC()) { ana_tec_pid(); cout << "\n ana_tec_pid finished" << endl; } if (precoSelect::isTOF() && precoSelect::isCGL()) { ana_tof_pid(); cout << "\n ana_tof_pid finished" << endl; } if(precoSelect::isMUTR() || precoSelect::isMUID()) { MutGetGEA(topNode); MuiGetGEA(topNode); ana_mui(); cout << "\n ana_mui finished" << endl; } if(precoSelect::isDISP()){ ana_disp(); } // // End of event processing // relOut->write(evaNode); // evaluation node is written for both PISA-to-DST and PISA-to-PRDF if(simulationFlag == 2) { simDstOut->write(dstNode); // DST is written only when simulationFlag = 2 if(precoSelect::isCGL() && getPadTrackEvaluate()) ana_pad_evaluate(topNode); } if(simulationFlag == 3) PHBoolean prdfStatus = prdfOut->write(prdfNode); // PRDF is written only for simulation flag = 3 // Reset all data for this event PHNodeIterator mainIter(topNode); PHNodeReset reset; if (mainIter.cd("DST")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("DCM")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("GEA")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("EVA")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("BBC")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("MVD")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("PAD")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("CRK")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("TEC")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("EMC")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("TOF")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("DCH")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("CGL")) { mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("MUI")) { // cout << "\n In MUI " << endl; mainIter.forEach(reset); mainIter.cd(); } if (mainIter.cd("MUT")) { // cout << "\n In MUT " << endl; mainIter.forEach(reset); mainIter.cd(); } pisaRun->HitsClear(); } // loop over requested events return 0; } int pisaFileEnd() { delete relOut; // the evaluation file exists for both PISA-to-DST and PISA-to-PRDF if(simulationFlag == 2) { delete simDstOut; // the DST file exists only for PISA-to-DST if(precoSelect::isCGL() && getPadTrackEvaluate()) ana_pad_close(); } if(simulationFlag == 3) delete prdfOut; // the PRDF file exists only for PISA-to-PRDF pisaFile->Close(); return 0; } void setPadTrackEvaluate(int padTrackFlag) { padTrackEvaluateFlag = padTrackFlag; } Int_t getPadTrackEvaluate() { return padTrackEvaluateFlag; } void setSimVertexFlag(int vertexFlag, float z0VertexSimulation, float t0VertexSimulation, float z0VertexSimulationWidth, float t0VertexSimulationWidth) { simVertexFlag = vertexFlag; simZ0Vertex = z0VertexSimulation; simT0Vertex = t0VertexSimulation; simZ0VertexWidth = z0VertexSimulationWidth; simT0VertexWidth = t0VertexSimulationWidth; if(vertexFlag == 1) { cout << "\n setSimVertexFlag : Z0 vertex set at " << simZ0Vertex << " cm"; cout << ", T0 set at " << simT0Vertex; cout << "\n setSimVertexFlag : Z0 vertex width set at " << simZ0VertexWidth << " cm"; cout << ", T0 width set at " << simT0VertexWidth << endl; } if(vertexFlag == 2) { cout << "\n setSimVertexFlag : Z0 vertex set according to event header in PISA"; cout << ", T0 set at " << simT0Vertex; cout << "\n setSimVertexFlag : Z0 vertex width set at " << simZ0VertexWidth << " cm"; cout << ", T0 width set at " << simT0VertexWidth << endl; } return; } int getSimVertexFlag() { if(simVertexFlag == 1 || simVertexFlag == 2) { if(simVertexFlag == 1) cout << "\n getSimVertexFlag : Z0 vertex set at " << simZ0Vertex << " cm, with width " << simZ0VertexWidth << endl; else cout << "\n setSimVertexFlag : Z0 vertex set according to event header in PISA, with width " << simZ0VertexWidth << endl; cout << " T0 set at " << simT0Vertex << " ps, with width " << simT0VertexWidth << endl; } else { cout << "\n getSimVertexFlag : simVertexFlag has not been set" << endl; } return simVertexFlag; } void simSetBbcOut() { PHTypedNodeIterator BbcOutIter(topNode); PHIODataNode *BbcOutNode = BbcOutIter.find("BbcOut"); if(BbcOutNode) { BbcOutv1* BbcOut = (BbcOutv1*)BbcOutNode->getData(); if(simVertexFlag == 2) { PISAEventHeader *pisaEventHeader = PISAEventHeader::GetEventHeader(); simZ0Vertex = pisaEventHeader->GetZvertex(); } // check on different Event Z0 from PISA event header record Float_t randomizedZ0Vertex = simZ0Vertex; Float_t randomizedT0Vertex = simT0Vertex; if(simZ0VertexWidth>0.0) randomizedZ0Vertex = gRandom->Gaus(simZ0Vertex, simZ0VertexWidth); if(simT0VertexWidth>0.0) randomizedT0Vertex = gRandom->Gaus(simT0Vertex, simT0VertexWidth); BbcOut->set_TimeVertex(randomizedT0Vertex, 0.0, randomizedZ0Vertex, 0.0); float bbcZVertex = BbcOut->get_VertexPoint(); if(simVertexFlag == 1) cout << "\n simSetBbcOut : bbcZVertex including any randomization = " << bbcZVertex << endl; else cout << "\n simSetBbcOut : bbcZVertex from PISA Event after any randomization = " << bbcZVertex << endl; } else { cout << "\n simSetBbcOut : Unable to find BbcOut node " << endl; exit(1); } return; }