00001 #include "NtpMaker.h"
00002 #include "AtmosCalculator.h"
00003
00004 #include "AtNuEvent/AtmosEvent.h"
00005 #include "AtNuEvent/AtmosScintHit.h"
00006 #include "AtNuEvent/AtmosStdHEP.h"
00007 #include "AtNuEvent/AtmosDeadChip.h"
00008 #include "AtNuEvent/AtmosShieldPlank.h"
00009 #include "AtNuEvent/AtmosStrip.h"
00010 #include "AtNuEvent/AtmosShower.h"
00011 #include "AtNuEvent/AtmosTrack.h"
00012
00013 #include "MessageService/MsgService.h"
00014 #include "MinosObjectMap/MomNavigator.h"
00015 #include "JobControl/JobCModuleRegistry.h"
00016
00017 #include "RerootExodus/RerootExodus.h"
00018 #include "REROOT_Classes/REROOT_NeuKin.h"
00019 #include "Record/SimSnarlRecord.h"
00020 #include "Record/SimSnarlHeader.h"
00021 #include "Digitization/DigiSignal.h"
00022 #include "Digitization/DigiScintHit.h"
00023
00024 #include "RawData/RawRecord.h"
00025 #include "RawData/RawSnarlHeaderBlock.h"
00026 #include "RawData/RawDigit.h"
00027 #include "RawData/RawDigitDataBlock.h"
00028 #include "RawData/RawDaqSnarlHeader.h"
00029
00030 #include "CandData/CandRecord.h"
00031 #include "CandData/CandHeader.h"
00032 #include "CandMorgue/CandDataQualityHandle.h"
00033 #include "CandMorgue/CandDeadChipHandle.h"
00034 #include "CandDigit/CandDeMuxDigitHandle.h"
00035 #include "CandDigit/CandDeMuxDigitListHandle.h"
00036 #include "RecoBase/CandStripHandle.h"
00037 #include "RecoBase/CandStripListHandle.h"
00038 #include "RecoBase/CandSliceHandle.h"
00039 #include "RecoBase/CandSliceListHandle.h"
00040 #include "RecoBase/CandShowerHandle.h"
00041 #include "RecoBase/CandShowerListHandle.h"
00042 #include "RecoBase/CandTrackListHandle.h"
00043 #include "RecoBase/CandTrackHandle.h"
00044 #include "RecoBase/CandFitTrackListHandle.h"
00045 #include "RecoBase/CandFitTrackHandle.h"
00046
00047 #include "Calibrator/Calibrator.h"
00048 #include "OnlineUtil/mdSpillData.h"
00049 #include "SpillTiming/SpillTimeFinder.h"
00050 #include "BeamDataUtil/BeamMonSpill.h"
00051 #include "BeamDataUtil/BDSpillAccessor.h"
00052 #include "BeamDataUtil/BMSpillAna.h"
00053 #include "UgliGeometry/UgliGeomHandle.h"
00054 #include "UgliGeometry/UgliStripHandle.h"
00055 #include "Plex/PlexHandle.h"
00056 #include "Plex/PlexStripEndId.h"
00057 #include "Plex/PlexPlaneId.h"
00058
00059 #include "FarDetShieldPlankListHandle.h"
00060 #include "FarDetShieldPlankHandle.h"
00061 #include "FarDetStripListHandle.h"
00062 #include "FarDetStripHandle.h"
00063 #include "FarDetSliceListHandle.h"
00064 #include "FarDetSliceHandle.h"
00065 #include "FarDetEventListHandle.h"
00066 #include "FarDetEventHandle.h"
00067
00068 #include "TClonesArray.h"
00069 #include <vector>
00070 #include "TParticle.h"
00071
00072 #include <cmath>
00073
00074 using std::vector;
00075
00076 JOBMODULE(NtpMaker,"NtpMaker","Make Ntps");
00077
00078 CVSID("$Id: NtpMaker.cxx,v 1.30 2009/02/13 15:03:01 blake Exp $");
00079
00080 NtpMaker::NtpMaker()
00081 {
00082 MSG("NtpMaker",Msg::kDebug) << " *** NtpMaker::NtpMaker() *** " << endl;
00083
00084 fFile = 0;
00085 fTree = 0;
00086 fNtpName = "ntp.root";
00087 fMaxFileSizeBytes = 0.0;
00088 fFileNumber = 1;
00089 fWriteStrips = true;
00090 fWriteScintHits = true;
00091 fWriteStdHEPs = true;
00092 fEvent = new AtmosEvent();
00093 }
00094
00095
00096
00097 NtpMaker::~NtpMaker()
00098 {
00099 MSG("NtpMaker",Msg::kDebug) << " *** NtpMaker::~NtpMaker() *** " << endl;
00100 }
00101
00102
00103
00104 void NtpMaker::BeginJob()
00105 {
00106 MSG("NtpMaker",Msg::kDebug) << " *** NtpMaker::BeginJob() *** " << endl;
00107
00108 }
00109
00110
00111
00112 JobCResult NtpMaker::Ana(const MomNavigator* mom)
00113 {
00114 MSG("NtpMaker",Msg::kDebug) << " *** NtpMaker::Ana(...) *** " << endl;
00115
00116 JobCResult result(JobCResult::kPassed);
00117 Int_t simflag=-1;
00118 Int_t run=-1, subrun=-1, snarl=-1;
00119 Int_t runtype=-1, trigsrc=-1, timeframe=-1;
00120 Int_t date=-1, time=-1, microsec=-1, nanosec=-1, unixtime=-1;
00121 Int_t ndigits=-1;
00122 fEvent->Reset();
00123
00124
00125 SimSnarlRecord* simrec = dynamic_cast<SimSnarlRecord *>(mom->GetFragment("SimSnarlRecord"));
00126 if(simrec)
00127 {
00128 MSG("NtpMaker",Msg::kDebug) << " *** PROCESS SIMSNARLRECORD *** " << endl;
00129
00130 if(simflag<0) simflag = simrec->GetVldContext()->GetSimFlag();
00131
00132 if(run<0) run=RerootExodus::GetRunNo();
00133 if(snarl<0) snarl=RerootExodus::GetEventNo();
00134
00135 const SimSnarlHeader* hdr = dynamic_cast<const SimSnarlHeader*>(simrec->GetSimSnarlHeader());
00136 if(hdr)
00137 {
00138 if(run<0) run = hdr->GetRun();
00139 if(subrun<0) subrun = hdr->GetSubRun();
00140 if(snarl<0) snarl = hdr->GetSnarl();
00141 if(runtype<0) runtype = hdr->GetRunType();
00142 }
00143
00144 this->FillMCInfo(simrec);
00145 }
00146
00147
00148 RawRecord* rawrec = dynamic_cast<RawRecord*>(mom->GetFragment("RawRecord"));
00149 if(rawrec)
00150 {
00151 MSG("NtpMaker",Msg::kDebug) << " *** PROCESS RAWRECORD *** " << endl;
00152
00153 if(simflag<0) simflag = rawrec->GetVldContext()->GetSimFlag();
00154
00155 const RawDaqSnarlHeader* hdr = dynamic_cast<const RawDaqSnarlHeader*>(rawrec->GetRawHeader());
00156 if(hdr)
00157 {
00158
00159 if(run<0) run = hdr->GetRun();
00160 if(subrun<0) subrun = hdr->GetSubRun();
00161 if(snarl<0) snarl = hdr->GetSnarl();
00162 if(runtype<0) runtype = hdr->GetRunType();
00163 if(trigsrc<0) trigsrc = hdr->GetTrigSrc();
00164 if(timeframe<0) timeframe = hdr->GetTimeFrameNum();
00165 if(ndigits<0) ndigits = hdr->GetNumRawDigits();
00166 if(unixtime<0) unixtime = ((VldTimeStamp)(hdr->GetVldContext().GetTimeStamp())).GetSec();
00167 if(date<0) date = (((VldTimeStamp)(hdr->GetVldContext().GetTimeStamp())).GetSec()-1059696000)/(3600*24);
00168 if(time<0) time = (((VldTimeStamp)(hdr->GetVldContext().GetTimeStamp())).GetSec()-1059696000)%(3600*24);
00169 if(nanosec<0) nanosec = (Int_t)(1.000*(((VldTimeStamp)(hdr->GetVldContext().GetTimeStamp())).GetNanoSec()));
00170 if(microsec<0) microsec = (Int_t)(0.001*(((VldTimeStamp)(hdr->GetVldContext().GetTimeStamp())).GetNanoSec()));
00171 if(fEvent->SpillInfo.spilltype<0) fEvent->SpillInfo.spilltype = hdr->GetRemoteSpillType();
00172 }
00173 this->FillRawInfo(rawrec);
00174 }
00175
00176
00177 CandRecord* candrec = dynamic_cast<CandRecord*>(mom->GetFragment("CandRecord"));
00178 if(candrec)
00179 {
00180 MSG("NtpMaker",Msg::kDebug) << " *** PROCESS CANDRECORD *** " << endl;
00181
00182 if(simflag<0) simflag = candrec->GetVldContext()->GetSimFlag();
00183
00184 const CandHeader* hdr = dynamic_cast<const CandHeader*>(candrec->GetHeader());
00185 if(hdr)
00186 {
00187 Calibrator& cal = Calibrator::Instance();
00188 cal.ReInitialise(hdr->GetVldContext());
00189
00190 if(run<0) run = hdr->GetRun();
00191 if(snarl<0) snarl = hdr->GetSnarl();
00192 if(unixtime<0) unixtime = ((VldTimeStamp)(hdr->GetVldContext().GetTimeStamp())).GetSec();
00193 if(date<0) date = (((VldTimeStamp)(hdr->GetVldContext().GetTimeStamp())).GetSec()-1059696000)/(3600*24);
00194 if(time<0) time = (((VldTimeStamp)(hdr->GetVldContext().GetTimeStamp())).GetSec()-1059696000)%(3600*24);
00195 if(nanosec<0) nanosec = (Int_t)(1.000*(((VldTimeStamp)(hdr->GetVldContext().GetTimeStamp())).GetNanoSec()));
00196 if(microsec<0) microsec = (Int_t)(0.001*(((VldTimeStamp)(hdr->GetVldContext().GetTimeStamp())).GetNanoSec()));
00197 }
00198
00199 this->FillCandInfo(candrec);
00200 }
00201
00202 fEvent->Run = run;
00203 fEvent->SubRun = subrun;
00204 fEvent->Snarl = snarl;
00205 fEvent->RunType = runtype;
00206 fEvent->TrigSrc = trigsrc;
00207 fEvent->TimeFrame = timeframe;
00208 fEvent->Date = date;
00209 fEvent->Time = time;
00210 fEvent->MicroSec = microsec;
00211 fEvent->NanoSec = nanosec;
00212 fEvent->UnixTime = unixtime;
00213 fEvent->Ndigits = ndigits;
00214 fEvent->SimFlag = simflag;
00215
00216 MSG("NtpMaker",Msg::kDebug) << " *** EVENT SUMMARY *** " << endl
00217 << " Run = " << fEvent->Run << endl
00218 << " SubRun = " << fEvent->SubRun << endl
00219 << " Snarl = " << fEvent->Snarl << endl
00220 << " RunType = " << fEvent->RunType << endl
00221 << " TrigSrc = " << fEvent->TrigSrc << endl
00222 << " TimeFrame = " << fEvent->TimeFrame << endl
00223 << " Date = " << fEvent->Date << endl
00224 << " Time = " << fEvent->Time << endl
00225 << " MicroSec = " << fEvent->MicroSec << endl
00226 << " NanoSec = " << fEvent->NanoSec << endl
00227 << " UnixTime = " << fEvent->UnixTime << endl
00228 << " Ndigits = " << fEvent->Ndigits << endl
00229 << " SimFlag = " << fEvent->SimFlag << endl;
00230
00231
00232 MSG("NtpMaker",Msg::kInfo) << " *** NtpMaker: " << fEvent->Run << "/" << fEvent->SubRun << " " << fEvent->Snarl << " DONE *** " << endl;
00233
00234
00235 if (!fWriteStrips)
00236 {
00237 fEvent->NStrips = 0;
00238 fEvent->StripList->Clear();
00239 }
00240
00241
00242 if (!fWriteScintHits)
00243 {
00244 fEvent->NScintHits = 0;
00245 fEvent->ScintHitList->Clear();
00246 }
00247
00248
00249 if (!fWriteStdHEPs)
00250 {
00251 fEvent->NStdHEPs = 0;
00252 fEvent->StdHEPList->Clear();
00253 }
00254
00255
00256 if(!fFile)
00257 {
00258 MSG("NtpMaker",Msg::kInfo) << " CREATING OUTPUT FILE: " << fNtpName.Data() << endl;
00259
00260
00261 TDirectory *tmpd = gDirectory;
00262 fFile = TFile::Open(fNtpName.Data(), "recreate");
00263 fTree = new TTree("ntp", "FarDet Atmos Events");
00264 fTree->SetDirectory(fFile);
00265 fTree->Branch("evt", "AtmosEvent", &fEvent);
00266 fTree->SetAutoSave(100);
00267 tmpd->cd();
00268 }
00269
00270
00271 if( fFile
00272 && fMaxFileSizeBytes>0
00273 && fFile->GetBytesWritten()>fMaxFileSizeBytes )
00274 {
00275 MSG("NtpMaker",Msg::kWarning) << " FILE SIZE EXCEEDS LIMIT (" << 1.0e-6*fFile->GetBytesWritten() << ">" << 1.0e-6*fMaxFileSizeBytes << ")" << endl;
00276 MSG("NtpMaker",Msg::kWarning) << " ... SWITCHING TO NEW FILE" << endl;
00277
00278
00279 TDirectory *tmpd = gDirectory;
00280 fFile->cd();
00281 fFile->Write();
00282 fFile->Close();
00283 gDirectory = tmpd;
00284
00285
00286 fFileNumber++;
00287 TDirectory *tmpd2 = gDirectory;
00288 TString filename = fNtpName;
00289 TString tempfilename = ".";
00290 tempfilename += fFileNumber;
00291
00292 if( filename.EndsWith(".root") ){
00293 filename.Insert(filename.Length()-5,tempfilename);
00294 }
00295 else{
00296 filename.Append(tempfilename);
00297 }
00298
00299 MSG("NtpMaker",Msg::kWarning) << " ... CREATING NEW OUTPUT FILE: " << filename.Data() << endl;
00300
00301
00302 fFile = TFile::Open(filename.Data(), "recreate");
00303 fTree = new TTree("ntp", "FarDet Atmos Events");
00304 fTree->SetDirectory(fFile);
00305 fTree->Branch("evt", "AtmosEvent", &fEvent);
00306 fTree->SetAutoSave(100);
00307 tmpd2->cd();
00308 }
00309
00310
00311 if(!fFile)
00312 {
00313 MSG("NtpMaker",Msg::kError) << " Can't find output file: " << fNtpName.Data() << endl;
00314 MSG("NtpMaker",Msg::kFatal) << " Aaaggghhh... " << endl;
00315 assert(0);
00316 }
00317 if(!fTree)
00318 {
00319 MSG("NtpMaker",Msg::kError) << " Can't find output tree: " << fNtpName.Data() << endl;
00320 MSG("NtpMaker",Msg::kFatal) << " Aaaggghhh... " << endl;
00321 assert(0);
00322 }
00323
00324
00325 if(fFile)
00326 {
00327 MSG("NtpMaker",Msg::kDebug) << " writing event to file... " << endl;
00328 Int_t filesize(0),filesizeNew(0);
00329
00330 TDirectory* tmpd = gDirectory;
00331 filesize = fFile->GetBytesWritten();
00332 fFile->cd();
00333 fTree->Fill();
00334 filesizeNew = fFile->GetBytesWritten();
00335 gDirectory = tmpd;
00336
00337 MSG("NtpMaker",Msg::kDebug) << " ... bytes written: " << filesizeNew-filesize << endl;
00338 MSG("NtpMaker",Msg::kDebug) << " ... current file size: " << filesizeNew << endl;
00339 }
00340
00341 return result;
00342 }
00343
00344
00345
00346 const Registry& NtpMaker::DefaultConfig() const
00347 {
00348 MSG("NtpMaker",Msg::kDebug) << " *** NtpMaker::DefaultConfig() *** " << endl;
00349
00350
00351 static Registry r;
00352 std::string name = this->GetName();
00353 name += ".config.default";
00354 r.SetName(name.c_str());
00355 r.UnLockKeys();
00356 r.UnLockValues();
00357 r.Set("NtpFileName","ntp.root");
00358 r.Set("MaxFileSize",0);
00359 r.Set("WriteStrips",1);
00360 r.Set("WriteScintHits",1);
00361 r.Set("WriteStdHEPs",1);
00362 r.LockValues();
00363 r.LockKeys();
00364 return r;
00365 }
00366
00367
00368
00369 void NtpMaker::Config(const Registry& r)
00370 {
00371 MSG("NtpMaker",Msg::kDebug) << " *** NtpMaker::Config(...) *** " << endl;
00372
00373
00374 Int_t tmpint; const char* tmpchar = 0;
00375 if(r.Get("NtpFileName",tmpchar)) { fNtpName = tmpchar; }
00376 if(r.Get("MaxFileSize",tmpint)) { fMaxFileSizeBytes = 1.0e6*tmpint; }
00377 if(r.Get("WriteStrips",tmpint)) { fWriteStrips = (Bool_t)tmpint; }
00378 if(r.Get("WriteScintHits",tmpint)) { fWriteScintHits = (Bool_t)tmpint; }
00379 if(r.Get("WriteStdHEPs",tmpint)) { fWriteStdHEPs = (Bool_t)tmpint; }
00380 }
00381
00382
00383
00384 void NtpMaker::EndJob()
00385 {
00386 MSG("NtpMaker",Msg::kDebug) << " *** NtpMaker::EndJob(...) *** " << endl;
00387 if( !fFile )
00388 {
00389
00390 MSG("NtpMaker",Msg::kWarning) << " *** NTPMAKER: CREATING EMPTY OUTPUT FILE *** " << endl;
00391 TDirectory *tmpd = gDirectory;
00392 fFile = TFile::Open(fNtpName.Data(), "recreate");
00393 fTree = new TTree("ntp", "FarDet Atmos Events");
00394 fTree->SetDirectory(fFile);
00395 fTree->Branch("evt", "AtmosEvent", &fEvent);
00396 fTree->SetAutoSave(100);
00397 tmpd->cd();
00398 }
00399
00400 if( fFile )
00401 {
00402 TDirectory* tmpd = gDirectory;
00403 fFile->cd();
00404 MSG("NtpMaker",Msg::kDebug) << " WRITING FILE: " << fFile->GetBytesWritten() << " bytes (before)" << endl;
00405 fFile->Write();
00406 MSG("NtpMaker",Msg::kDebug) << " WRITING FILE: " << fFile->GetBytesWritten() << " bytes (after)" << endl;
00407 fFile->Close();
00408 gDirectory = tmpd;
00409 }
00410 }
00411
00412
00413
00414 void NtpMaker::FillCandInfo(CandRecord* candrec)
00415 {
00416 MSG("NtpMaker",Msg::kDebug) << " *** NtpMaker::FillCandInfo(...) *** " << endl;
00417
00418
00419 TIter candbit(candrec->GetCandHandleIter());
00420 while(TObject* tob = (TObject*)(candbit()))
00421 {
00422 MSG("NtpMaker",Msg::kDebug) << tob->GetName() << endl;
00423
00424 if(tob->InheritsFrom("CandDataQualityHandle"))
00425 {
00426 FillDataQualityInfo(tob); continue;
00427 }
00428
00429 if(tob->InheritsFrom("CandDeMuxDigitListHandle"))
00430 {
00431 FillDeMuxInfo(tob); continue;
00432 }
00433 if(tob->InheritsFrom("FarDetShieldPlankListHandle"))
00434 {
00435 FillShieldInfo(tob); continue;
00436 }
00437
00438 if(tob->InheritsFrom("FarDetStripListHandle"))
00439 {
00440 FillStripInfo(tob); continue;
00441 }
00442
00443 if(tob->InheritsFrom("FarDetSliceListHandle"))
00444 {
00445 FillSliceInfo(tob); continue;
00446 }
00447
00448 if(tob->InheritsFrom("CandFitTrackListHandle"))
00449 {
00450 FillFitTrackInfo(tob); continue;
00451 }
00452
00453 if(tob->InheritsFrom("CandTrackListHandle"))
00454 {
00455 FillTrackInfo(tob); continue;
00456 }
00457
00458 if(tob->InheritsFrom("CandShowerListHandle"))
00459 {
00460 FillShowerInfo(tob); continue;
00461 }
00462
00463 if(tob->InheritsFrom("FarDetEventListHandle"))
00464 {
00465 FillEventInfo(tob); continue;
00466 }
00467 MSG("NtpMaker",Msg::kDebug) << " NtpMaker has no use for " << tob->GetName() <<endl;
00468 }
00469
00470
00471
00472
00473 MSG("NtpMaker",Msg::kDebug) << " Running AtmosCalculator..." << endl;
00474 AtmosCalculator AtmosCalc;
00475 TClonesArray& MyFitList = *(fEvent->TrackList);
00476 TClonesArray* MyStrpList = (fEvent->StripList);
00477 TClonesArray& MyShowerList = *(fEvent->ShowerList);
00478
00479 int trklimit = MyFitList.GetLast()+1;
00480 for(int i=0; i<trklimit; ++i)
00481 {
00482 AtmosTrack* MyFit = (AtmosTrack*)(MyFitList[i]);
00483 AtmosCalc.TrackProperties(MyFit,MyStrpList);
00484 }
00485
00486 int shwlimit = MyShowerList.GetLast()+1;
00487 for(int i=0; i<shwlimit; ++i)
00488 {
00489 AtmosShower* MyShower = (AtmosShower*)(MyShowerList[i]);
00490 AtmosCalc.ShowerProperties(MyShower,MyStrpList);
00491 }
00492
00493 AtmosCalc.EventProperties(fEvent,MyStrpList);
00494
00495 MSG("NtpMaker",Msg::kDebug) << " ... AtmosCalculator Finished" << endl;
00496
00497 return;
00498 }
00499
00500
00501
00502 void NtpMaker::FillDataQualityInfo(TObject* tob)
00503 {
00504
00505
00506 CandDataQualityHandle* Data = (CandDataQualityHandle*)(tob);
00507 MSG("NtpMaker",Msg::kDebug) << " ... found CandDataQualityHandle " << endl;
00508 TClonesArray& MyDeadChipList = *(fEvent->DeadChipList);
00509
00510 fEvent->DataInfo.TriggerSource = Data->GetTriggerSource();
00511 fEvent->DataInfo.TriggerTime = Data->GetTriggerTime();
00512 fEvent->DataInfo.ErrorCode = Data->GetErrorCode();
00513 fEvent->DataInfo.CrateMask = Data->GetCrateMask();
00514 fEvent->DataInfo.PreTriggerDigits = Data->GetPreTriggerDigits();
00515 fEvent->DataInfo.PostTriggerDigits = Data->GetPostTriggerDigits();
00516 fEvent->DataInfo.SnarlMultiplicity = Data->GetSnarlMultiplicity();
00517 fEvent->DataInfo.SpillStatus = Data->GetSpillStatus();
00518 fEvent->DataInfo.SpillType = Data->GetSpillType();
00519 fEvent->DataInfo.SpillTimeError = Data->GetSpillTimeError();
00520 fEvent->DataInfo.LiTrigger = Data->GetLiTrigger();
00521 fEvent->DataInfo.LiTime = Data->GetLiTime();
00522 fEvent->DataInfo.LiSubtractedTime = Data->GetLiSubtractedTime();
00523 fEvent->DataInfo.LiRelativeTime = Data->GetLiRelativeTime();
00524 fEvent->DataInfo.LiCalibPoint = Data->GetLiCalibPoint();
00525 fEvent->DataInfo.LiCalibType = Data->GetLiCalibType();
00526 fEvent->DataInfo.LiPulserBox = Data->GetLiPulserBox();
00527 fEvent->DataInfo.LiPulserLed = Data->GetLiPulserLed();
00528 fEvent->DataInfo.LiPulseHeight = Data->GetLiPulseHeight();
00529 fEvent->DataInfo.LiPulseWidth = Data->GetLiPulseWidth();
00530 fEvent->DataInfo.ColdChips = Data->GetColdChips();
00531 fEvent->DataInfo.HotChips = Data->GetHotChips();
00532 fEvent->DataInfo.BusyChips = Data->GetBusyChips();
00533 fEvent->DataInfo.ReadoutErrors = Data->GetReadoutErrors();
00534 fEvent->DataInfo.DataQualityBitMap = (Int_t)Data->GetDataQuality();
00535
00536
00537 PlexHandle plex(*(Data->GetVldContext()));
00538 TIter DataItr(Data->GetDaughterIterator());
00539 while(CandDeadChipHandle* DeadChip = dynamic_cast<CandDeadChipHandle*>(DataItr()))
00540 {
00541 AtmosDeadChip* MyDeadChip = new( MyDeadChipList[(fEvent->NDeadChips)++] ) AtmosDeadChip();
00542 RawChannelId rcid = DeadChip->GetChannelId();
00543
00544 MyDeadChip->Crate = rcid.GetCrate();
00545 MyDeadChip->Varc = rcid.GetVarcId();
00546 MyDeadChip->Vmm = rcid.GetVmm();
00547 MyDeadChip->VaAdc = rcid.GetVaAdcSel();
00548 MyDeadChip->VaChip = rcid.GetVaChip();
00549 RawChannelId rcidCheck = RawChannelId(Detector::kFar,ElecType::kVA,
00550 MyDeadChip->Crate, MyDeadChip->Varc,
00551 MyDeadChip->Vmm, MyDeadChip->VaAdc,
00552 MyDeadChip->VaChip, 10);
00553
00554 if( plex.GetSEIdAltL(rcidCheck).IsValid() && plex.GetSEIdAltL(rcidCheck).GetPlane()>=0 && plex.GetSEIdAltL(rcidCheck).GetPlane()<1000 )
00555 {
00556 MyDeadChip->InReadout = 1;
00557
00558
00559 if(plex.GetSEIdAltL(rcidCheck).IsVetoShield())
00560 {
00561 MyDeadChip->Shield = 1;
00562 }
00563
00564
00565 if(!plex.GetSEIdAltL(rcidCheck).IsVetoShield())
00566 {
00567
00568 RawChannelId rcidLow = RawChannelId(Detector::kFar,ElecType::kVA,
00569 MyDeadChip->Crate, MyDeadChip->Varc,
00570 MyDeadChip->Vmm, MyDeadChip->VaAdc,
00571 0,2);
00572
00573 RawChannelId rcidHigh = RawChannelId(Detector::kFar,ElecType::kVA,
00574 MyDeadChip->Crate, MyDeadChip->Varc,
00575 MyDeadChip->Vmm, MyDeadChip->VaAdc,
00576 1,17);
00577
00578 if(MyDeadChip->VaChip!=1) MyDeadChip->Plane[0] = plex.GetSEIdAltL(rcidLow).GetPlane();
00579 if(MyDeadChip->VaChip!=0) MyDeadChip->Plane[1] = plex.GetSEIdAltL(rcidHigh).GetPlane();
00580 }
00581 }
00582
00583 MyDeadChip->ErrorCode = DeadChip->GetErrorCode();
00584 MyDeadChip->Status = (Int_t)DeadChip->GetChipStatus();
00585 }
00586
00587 return;
00588 }
00589
00590
00591
00592 void NtpMaker::FillDeMuxInfo(TObject* tob)
00593 {
00594
00595 CandDeMuxDigitListHandle* DigitList = (CandDeMuxDigitListHandle*)(tob);
00596 MSG("NtpMaker",Msg::kDebug) << " ... found CandDeMuxDigitListHandle " << endl;
00597 fEvent->RecoInfo.Ndigits = DigitList->GetNDaughters();
00598 fEvent->RecoInfo.DeMuxFlagWord = DigitList->GetDeMuxDigitListFlagWord();
00599 fEvent->RecoInfo.MultipleMuonFlag = (Int_t)((DigitList->GetDeMuxDigitListFlagWord())&(CandDeMuxDigitList::kMultipleMuonEvent));
00600 fEvent->RecoInfo.AbsTime = DigitList->GetAbsTime();
00601
00602 fEvent->RecoInfo.Nplndigits = 0;
00603 TIter digitr(DigitList->GetDaughterIterator());
00604 while(CandDigitHandle* cdh = dynamic_cast<CandDigitHandle*>(digitr()))
00605 {
00606 if( cdh )
00607 {
00608 if( !cdh->GetPlexSEIdAltL().IsVetoShield()
00609 && cdh->GetPlexSEIdAltL().GetPlane()>=0
00610 && cdh->GetPlexSEIdAltL().GetPlane()<500
00611 && cdh->GetSubtractedTime()>=0 )
00612 {
00613 ++fEvent->RecoInfo.Nplndigits;
00614 }
00615 }
00616 }
00617
00618
00619 return;
00620 }
00621
00622
00623
00624 void NtpMaker::FillEventInfo(TObject* tob)
00625 {
00626 FarDetEventListHandle* EventList = (FarDetEventListHandle*)(tob);
00627 MSG("NtpMaker",Msg::kDebug) << " ... found FarDetEventListHandle " << endl;
00628
00629 if(EventList->GetNDaughters()<1)
00630 {
00631 MSG("NtpMaker",Msg::kWarning) << " ... FarDetEventListHandle has no daughters. " << endl;
00632 MSG("NtpMaker",Msg::kWarning) << " ... failed to find FarDetEventHandle " << endl;
00633 return;
00634 }
00635
00636 const FarDetEventHandle* Event = dynamic_cast<const FarDetEventHandle*>(EventList->GetDaughter(0));
00637
00638 if(Event==0)
00639 {
00640 MSG("NtpMaker",Msg::kWarning) << " ... failed to find FarDetEventHandle " << endl;
00641 return;
00642 }
00643 MSG("NtpMaker",Msg::kDebug) << " ... found FarDetEventHandle " << endl;
00644
00645 fEvent->RecoInfo.EMCharge = Event->GetEMCharge();
00646
00647 fEvent->RecoInfo.MuReco = Event->GetMuReco();
00648 fEvent->RecoInfo.MuMomentumRange = Event->GetMuMomentumRange();
00649 fEvent->RecoInfo.MuMomentumCurve = Event->GetMuMomentumCurve();
00650 fEvent->RecoInfo.MuDirCosU = Event->GetMuDirCosU();
00651 fEvent->RecoInfo.MuDirCosV = Event->GetMuDirCosV();
00652 fEvent->RecoInfo.MuDirCosZ = Event->GetMuDirCosZ();
00653 fEvent->RecoInfo.MuDirCosX = -999;
00654 fEvent->RecoInfo.MuDirCosY = -999;
00655 if( fEvent->RecoInfo.MuReco )
00656 {
00657 fEvent->RecoInfo.MuDirCosX = 0.7071*(Event->GetMuDirCosU()-Event->GetMuDirCosV());
00658 fEvent->RecoInfo.MuDirCosY = 0.7071*(Event->GetMuDirCosU()+Event->GetMuDirCosV());
00659 }
00660
00661 fEvent->RecoInfo.ShwReco = Event->GetShwReco();
00662 fEvent->RecoInfo.ShwMipsLinear = Event->GetShwMipsLinear();
00663 fEvent->RecoInfo.ShwMipsDeweighted = Event->GetShwMipsDeweighted();
00664 fEvent->RecoInfo.ShwEnergyGeVLinear = Event->GetShwEnergyGeVLinear();
00665 fEvent->RecoInfo.ShwEnergyGeVDeweighted = Event->GetShwEnergyGeVDeweighted();
00666 fEvent->RecoInfo.ShwDirCosU = Event->GetShwDirCosU();
00667 fEvent->RecoInfo.ShwDirCosV = Event->GetShwDirCosV();
00668 fEvent->RecoInfo.ShwDirCosZ = Event->GetShwDirCosZ();
00669 fEvent->RecoInfo.ShwDirCosX = -999;
00670 fEvent->RecoInfo.ShwDirCosY = -999;
00671 if( fEvent->RecoInfo.ShwReco )
00672 {
00673 fEvent->RecoInfo.ShwDirCosX = 0.7071*(Event->GetShwDirCosU()-Event->GetShwDirCosV());
00674 fEvent->RecoInfo.ShwDirCosY = 0.7071*(Event->GetShwDirCosU()+Event->GetShwDirCosV());
00675 }
00676
00677 fEvent->RecoInfo.VtxTime = Event->GetVtxTime();
00678 fEvent->RecoInfo.VtxU = Event->GetVtxU();
00679 fEvent->RecoInfo.VtxV = Event->GetVtxV();
00680 fEvent->RecoInfo.VtxX = 0.7071*(Event->GetVtxU()-Event->GetVtxV());
00681 fEvent->RecoInfo.VtxY = 0.7071*(Event->GetVtxU()+Event->GetVtxV());
00682 fEvent->RecoInfo.VtxZ = Event->GetVtxZ();
00683 fEvent->RecoInfo.VtxPlane = Event->GetVtxPlane();
00684
00685 fEvent->RecoInfo.MinPlane = Event->GetMinPlane();
00686 fEvent->RecoInfo.MaxPlane = Event->GetMaxPlane();
00687 fEvent->RecoInfo.MinZ = Event->GetMinZ();
00688 fEvent->RecoInfo.MaxZ = Event->GetMaxZ();
00689
00690 return;
00691
00692 }
00693
00694
00695
00696 void NtpMaker::FillFitTrackInfo(TObject* tob)
00697 {
00698 CandFitTrackListHandle* FitList = (CandFitTrackListHandle*)(tob);
00699 MSG("NtpMaker",Msg::kDebug) << " ... found CandFitTrackListHandle containing "<<FitList->GetNDaughters()<<" tracks."<< endl;
00700 float nstripcalib(0.0),stripsintrack(0.0);
00701 Calibrator& cal = Calibrator::Instance();
00702
00703
00704 TClonesArray* MyStrpList = (TClonesArray*)(fEvent->StripList);
00705 for(Int_t myint=0;myint<fEvent->NStrips;myint++)
00706 {
00707 AtmosStrip& MyStrp = *((AtmosStrip*)(MyStrpList->At(myint)));
00708 MyStrp.Trk = 0;
00709 MyStrp.dS = -999.9;
00710 }
00711
00712
00713
00714
00715 TClonesArray* MyFitList = (TClonesArray*)(fEvent->TrackList);
00716 TIter FitItr(FitList->GetDaughterIterator());
00717 fEvent->NFits = 0;
00718 while(CandFitTrackHandle* Fit = (CandFitTrackHandle*)(FitItr()))
00719 {
00720 if( fEvent->NFits < fEvent->NTracks )
00721 {
00722 AtmosTrack* MyFit = (AtmosTrack*)(MyFitList->At(fEvent->NFits++));
00723 MyFit->VtxPlane = Fit->GetVtxPlane();
00724 MyFit->VtxTime = Fit->GetVtxT();
00725 MyFit->VtxU = Fit->GetVtxU();
00726 MyFit->VtxV = Fit->GetVtxV();
00727 MyFit->VtxR = sqrt((MyFit->VtxU*MyFit->VtxU)+(MyFit->VtxV*MyFit->VtxV));
00728 MyFit->VtxX = 0.7071*(Fit->GetVtxU()-Fit->GetVtxV());
00729 MyFit->VtxY = 0.7071*(Fit->GetVtxU()+Fit->GetVtxV());
00730 MyFit->VtxZ = Fit->GetVtxZ();
00731 MyFit->VtxTrace = Fit->GetVtxTrace();
00732 MyFit->VtxTraceZ = Fit->GetVtxTraceZ();
00733 MyFit->VtxDirCosU = Fit->GetDirCosU();
00734 MyFit->VtxDirCosV = Fit->GetDirCosV();
00735 MyFit->VtxDirCosX = 0.7071*(Fit->GetDirCosU()-Fit->GetDirCosV());
00736 MyFit->VtxDirCosY = 0.7071*(Fit->GetDirCosU()+Fit->GetDirCosV());
00737 MyFit->VtxDirCosZ = Fit->GetDirCosZ();
00738 MyFit->EndPlane = Fit->GetEndPlane();
00739 MyFit->EndTime = Fit->GetEndT();
00740 MyFit->EndU = Fit->GetEndU();
00741 MyFit->EndV = Fit->GetEndV();
00742 MyFit->EndR = sqrt((MyFit->EndU*MyFit->EndU)+(MyFit->EndV*MyFit->EndV));
00743 MyFit->EndX = 0.7071*(Fit->GetEndU()-Fit->GetEndV());
00744 MyFit->EndY = 0.7071*(Fit->GetEndU()+Fit->GetEndV());
00745 MyFit->EndZ = Fit->GetEndZ();
00746 MyFit->EndTrace = Fit->GetEndTrace();
00747 MyFit->EndTraceZ = Fit->GetEndTraceZ();
00748 MyFit->EndDirCosU = Fit->GetEndDirCosU();
00749 MyFit->EndDirCosV = Fit->GetEndDirCosV();
00750 MyFit->EndDirCosX = 0.7071*(Fit->GetEndDirCosU()-Fit->GetEndDirCosV());
00751 MyFit->EndDirCosY = 0.7071*(Fit->GetEndDirCosU()+Fit->GetEndDirCosV());
00752 MyFit->EndDirCosZ = Fit->GetEndDirCosZ();
00753 MyFit->RangeGCM2 = Fit->GetRange(Fit->GetVtxPlane());
00754 MyFit->RangeMetres = Fit->GetdS(Fit->GetVtxPlane());
00755 MyFit->Nstrips = Fit->GetNStrip();
00756 MyFit->Nplanes = abs(MyFit->EndPlane-MyFit->VtxPlane)+1;
00757
00758 MyFit->TimingFitChi2 = Fit->GetTimeFitChi2();
00759 MyFit->TimingFitNdf = Fit->GetNTimeFitDigit()-2;
00760 MyFit->TimeSlope = Fit->GetTimeSlope();
00761 MyFit->TimeOffset = Fit->GetTimeOffset();
00762
00763 if(MyFit->EndPlane-MyFit->VtxPlane>0)
00764 {
00765 MyFit->VtxDirTimeFitRMS = Fit->GetTimeForwardFitRMS();
00766 MyFit->EndDirTimeFitRMS = Fit->GetTimeBackwardFitRMS();
00767 MyFit->VtxDirTimeFitNdf = Fit->GetTimeForwardFitNDOF();
00768 MyFit->EndDirTimeFitNdf = Fit->GetTimeBackwardFitNDOF();
00769 }
00770 else
00771 {
00772 MyFit->VtxDirTimeFitRMS = Fit->GetTimeBackwardFitRMS();
00773 MyFit->EndDirTimeFitRMS = Fit->GetTimeForwardFitRMS();
00774 MyFit->VtxDirTimeFitNdf = Fit->GetTimeBackwardFitNDOF();
00775 MyFit->EndDirTimeFitNdf = Fit->GetTimeForwardFitNDOF();
00776 }
00777
00778 MyFit->Momentum = Fit->GetMomentumCurve();
00779 MyFit->MomentumRange = Fit->GetMomentumRange();
00780 MyFit->MomentumCurve = Fit->GetMomentumCurve();
00781
00782 MyFit->FitPass = Fit->GetPass();
00783 MyFit->EMcharge = Fit->GetEMCharge();
00784 MyFit->QPvtxChi2 = Fit->GetChi2();
00785 MyFit->QPvtxNdf = Fit->GetNDOF();
00786 MyFit->QPvtx = Fit->GetPlaneQP(MyFit->VtxPlane);
00787 MyFit->QPvtxTweaked = (MyFit->Momentum!=0.0)?MyFit->EMcharge/MyFit->Momentum:0.0;
00788 MyFit->QPvtxErr = Fit->GetVtxQPError();
00789
00790 MyFit->Index = (int)pow(2.,fEvent->NFits-1);
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800 nstripcalib=(0.0); stripsintrack = Fit->GetNDaughters();
00801 TIter StrpItr(Fit->GetDaughterIterator());
00802 PlexStripEndId* seidP = 0;
00803 PlexStripEndId* seidN = 0;
00804 while(CandStripHandle* TrkStrp = (CandStripHandle*)(StrpItr()))
00805 {
00806 for(Int_t myint=0;myint<fEvent->NStrips;myint++)
00807 {
00808 AtmosStrip& MyStrp = *((AtmosStrip*)(MyStrpList->At(myint)));
00809
00810 if( TrkStrp->GetPlane()==MyStrp.Plane && TrkStrp->GetStrip()==MyStrp.Strip )
00811 {
00812 if( MyStrp.Trk==0 && Fit->IsTPosValid(MyStrp.Plane) )
00813 {
00814 if( MyStrp.View==0 )
00815 {
00816 MyStrp.L = Fit->GetV(MyStrp.Plane);
00817 MyStrp.dS = Fit->GetdS(MyStrp.Plane);
00818 MyStrp.GreenFibre[0] = MyStrp.HalfLength - MyStrp.L;
00819 MyStrp.GreenFibre[1] = MyStrp.HalfLength + MyStrp.L;
00820 seidN = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kNegative, StripEnd::kWhole, PlaneView::kU, PlaneCoverage::kTotal);
00821 seidP = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kPositive, StripEnd::kWhole, PlaneView::kU, PlaneCoverage::kTotal);
00822 }
00823 if( MyStrp.View==1 )
00824 {
00825 MyStrp.L = Fit->GetU(MyStrp.Plane);
00826 MyStrp.dS = Fit->GetdS(MyStrp.Plane);
00827 MyStrp.GreenFibre[0] = MyStrp.HalfLength + MyStrp.L;
00828 MyStrp.GreenFibre[1] = MyStrp.HalfLength - MyStrp.L;
00829 seidN = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kNegative, StripEnd::kWhole, PlaneView::kV, PlaneCoverage::kTotal);
00830 seidP = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kPositive, StripEnd::kWhole, PlaneView::kV, PlaneCoverage::kTotal);
00831 }
00832 double lsign = pow(-1.0, (1.0+double(MyStrp.View)) );
00833 if(seidN && MyStrp.Sigcorr[0]>0.0)
00834 {
00835 MyStrp.Sigmap[0] = cal.GetAttenCorrected(MyStrp.Sigcorr[0], lsign*MyStrp.L, *(seidN) );
00836 MyStrp.MIP[0] = cal.GetMIP(MyStrp.Sigmap[0], *(seidN) );
00837 }
00838 if(seidP && MyStrp.Sigcorr[1]>0.0)
00839 {
00840 MyStrp.Sigmap[1] = cal.GetAttenCorrected(MyStrp.Sigcorr[1], lsign*MyStrp.L, *(seidP) );
00841 MyStrp.MIP[1] = cal.GetMIP(MyStrp.Sigmap[1], *(seidP) );
00842 }
00843 if(MyStrp.Sigcorr[0]>0.0 || MyStrp.Sigcorr[1]>0.0) nstripcalib+=1.0;
00844 }
00845 MyStrp.Trk += MyFit->Index;
00846
00847 if(seidP) delete seidP; seidP = 0;
00848 if(seidN) delete seidN; seidN = 0;
00849
00850 break;
00851
00852
00853 }
00854 }
00855 }
00856
00857 MSG("NtpMaker",Msg::kVerbose) <<" "<<(int)stripsintrack<<" strips in the fitted track of which "<<(int)nstripcalib<<" were calibrated."<<endl<<flush;
00858 }
00859 }
00860 return;
00861 }
00862
00863
00864
00865 void NtpMaker::FillMCInfo(SimSnarlRecord* simrec)
00866 {
00867 MSG("NtpMaker",Msg::kDebug) << " *** NtpMaker::FillMCInfo(...) *** " << endl;
00868
00869 UgliGeomHandle ugh = (*(simrec->GetVldContext()));
00870 const TObjArray arr(simrec->GetComponents());
00871 TIter iter(arr.MakeIterator());
00872 while(TObject* tob = (TObject*)(iter()))
00873 {
00874 MSG("NtpMaker",Msg::kDebug) << tob->GetName() << endl;
00875
00876 if(tob->GetName()==TString("REROOT_NeuKin"))
00877 {
00878 REROOT_NeuKin* NeuKin = dynamic_cast<REROOT_NeuKin*>(tob);
00879 MSG("NtpMaker",Msg::kDebug) << " ... found REROOT_NeuKin " << endl;
00880 fEvent->MCInfo.IDnu = NeuKin->INu();
00881 fEvent->MCInfo.IDnunoosc = NeuKin->INuNoOsc();
00882 fEvent->MCInfo.IDact = NeuKin->IAction();
00883 fEvent->MCInfo.IDres = NeuKin->IResonance();
00884 fEvent->MCInfo.IDboson = NeuKin->IBoson();
00885 fEvent->MCInfo.IDtarget = NeuKin->ITg();
00886 fEvent->MCInfo.A = NeuKin->A();
00887 fEvent->MCInfo.Z = NeuKin->Z();
00888 fEvent->MCInfo.Xsection = NeuKin->Sigma();
00889 fEvent->MCInfo.EMfrac = NeuKin->EMFrac();
00890 fEvent->MCInfo.W2 = NeuKin->W2();
00891 fEvent->MCInfo.Q2 = NeuKin->Q2();
00892 fEvent->MCInfo.x = NeuKin->X();
00893 fEvent->MCInfo.y = NeuKin->Y();
00894 fEvent->MCInfo.PnuX = NeuKin->P4Neu()[0];
00895 fEvent->MCInfo.PnuY = NeuKin->P4Neu()[1];
00896 fEvent->MCInfo.PnuZ = NeuKin->P4Neu()[2];
00897 fEvent->MCInfo.Enu = NeuKin->P4Neu()[3];
00898 fEvent->MCInfo.PmuX = NeuKin->P4Mu1()[0];
00899 fEvent->MCInfo.PmuY = NeuKin->P4Mu1()[1];
00900 fEvent->MCInfo.PmuZ = NeuKin->P4Mu1()[2];
00901 fEvent->MCInfo.Emu = NeuKin->P4Mu1()[3];
00902 fEvent->MCInfo.PelX = NeuKin->P4El1()[0];
00903 fEvent->MCInfo.PelY = NeuKin->P4El1()[1];
00904 fEvent->MCInfo.PelZ = NeuKin->P4El1()[2];
00905 fEvent->MCInfo.Eel = NeuKin->P4El1()[3];
00906 fEvent->MCInfo.PhadX = NeuKin->P4Shw()[0];
00907 fEvent->MCInfo.PhadY = NeuKin->P4Shw()[1];
00908 fEvent->MCInfo.PhadZ = NeuKin->P4Shw()[2];
00909 fEvent->MCInfo.Ehad = NeuKin->P4Shw()[3];
00910 fEvent->MCInfo.PtargX = NeuKin->P4Tgt()[0];
00911 fEvent->MCInfo.PtargY = NeuKin->P4Tgt()[1];
00912 fEvent->MCInfo.PtargZ = NeuKin->P4Tgt()[2];
00913 fEvent->MCInfo.Etarg = NeuKin->P4Tgt()[3];
00914 }
00915
00916 if(tob->GetName()==TString("StdHep"))
00917 {
00918 TClonesArray* ParticleList = (TClonesArray*)(tob);
00919 MSG("NtpMaker",Msg::kDebug) << " ... found StdHep " << endl;
00920 TClonesArray& MyStdHEPList = *(fEvent->StdHEPList);
00921
00922 TParticle* Particle = dynamic_cast<TParticle*>(ParticleList->At(0));
00923 fEvent->MCInfo.VtxU = 0.7071*(Particle->Vy()+Particle->Vx());
00924 fEvent->MCInfo.VtxV = 0.7071*(Particle->Vy()-Particle->Vx());
00925 fEvent->MCInfo.VtxX = Particle->Vx();
00926 fEvent->MCInfo.VtxY = Particle->Vy();
00927 fEvent->MCInfo.VtxZ = Particle->Vz();
00928 TIter ParticleItr(ParticleList->MakeIterator());
00929 while( const TParticle* StdHEP = dynamic_cast<const TParticle*>(ParticleItr()))
00930 {
00931 AtmosStdHEP* MyStdHEP = new( MyStdHEPList[(fEvent->NStdHEPs)++] ) AtmosStdHEP();
00932 MyStdHEP->Index = fEvent->NStdHEPs - 1;
00933
00934 MyStdHEP->Parent[0] = StdHEP->GetMother(0);
00935 MyStdHEP->Parent[1] = StdHEP->GetMother(1);
00936 MyStdHEP->Child[0] = StdHEP->GetDaughter(0);
00937 MyStdHEP->Child[1] = StdHEP->GetDaughter(1);
00938 MyStdHEP->Id = StdHEP->GetPdgCode();
00939 MyStdHEP->Status = StdHEP->GetStatusCode();
00940 MyStdHEP->Mass = StdHEP->GetCalcMass();
00941 MyStdHEP->PX = StdHEP->Px();
00942 MyStdHEP->PY = StdHEP->Py();
00943 MyStdHEP->PZ = StdHEP->Pz();
00944 MyStdHEP->E = StdHEP->Energy();
00945 MyStdHEP->VtxX = StdHEP->Vx();
00946 MyStdHEP->VtxY = StdHEP->Vy();
00947 MyStdHEP->VtxX = StdHEP->Vz();
00948 MyStdHEP->VtxT = StdHEP->T();
00949 }
00950 }
00951
00952 if(tob->GetName()==TString("DigiScintHits"))
00953 {
00954 TClonesArray* ScintHitList = (TClonesArray*)(tob);
00955 MSG("NtpMaker",Msg::kDebug) << " ... found DigitScintHits " << endl;
00956 TClonesArray& MyScintHitList = *(fEvent->ScintHitList);
00957
00958 Int_t plane,strip;
00959 Int_t idnu,ipdg,trkid;
00960 Double_t u,v,x,y,z,r;
00961 Double_t xm,xp,ym,yp,um,up,vm,vp;
00962 Double_t muvtxU,muvtxV;
00963 Double_t muvtxX,muvtxY,muvtxZ;
00964 Double_t muvtxR,muendR;
00965 Double_t muendU,muendV;
00966 Double_t muendX,muendY,muendZ;
00967 Int_t muvtxpln,muendpln;
00968 Int_t muvtxstrp,muendstrp;
00969 Double_t pmu,maxpmu,minpmu;
00970
00971 muvtxU=0.0; muvtxV=0.0;
00972 muvtxX=0.0; muvtxY=0.0; muvtxZ=0.0;
00973 muendU=0.0; muendV=0.0;
00974 muendX=0.0; muendY=0.0; muendZ=0.0;
00975 muvtxR=999.9; muendR=999.9;
00976 muvtxpln=-999; muendpln=-999;
00977 muvtxstrp=-999; muendstrp=-999;
00978 maxpmu=-999.9; minpmu=-999.9;
00979
00980 PlexStripEndId seid;
00981 UgliStripHandle ush;
00982 TVector3 myglobal;
00983 TIter ScintHitItr(ScintHitList->MakeIterator());
00984 while( const DigiScintHit* ScintHit = dynamic_cast<const DigiScintHit*>(ScintHitItr()))
00985 {
00986 if( ScintHit->DE()<1.0E-4 && abs(ScintHit->ParticleId())!=13 ) continue;
00987
00988
00989 AtmosScintHit* MyScintHit = new( MyScintHitList[(fEvent->NScintHits)++] ) AtmosScintHit();
00990 MyScintHit->Id = ScintHit->ParticleId();
00991 MyScintHit->TrkId = ScintHit->TrackId();
00992 MyScintHit->Plane = ScintHit->Plane();
00993 MyScintHit->Strip = ScintHit->Strip();
00994
00995 seid = ScintHit->StripEndId();
00996 MyScintHit->View = -1;
00997 if(seid.GetPlaneView()==PlaneView::kU) MyScintHit->View = 0;
00998 if(seid.GetPlaneView()==PlaneView::kV) MyScintHit->View = 1;
00999
01000 ush = ugh.GetStripHandle(seid);
01001
01002 TVector3 mylocal( ScintHit->X1(), ScintHit->Y1(), ScintHit->Z1() );
01003 myglobal = ush.LocalToGlobal(mylocal);
01004
01005
01006
01007 MyScintHit->U[0] = float(0.7071*(myglobal.Y()+myglobal.X()));
01008 MyScintHit->V[0] = float(0.7071*(myglobal.Y()-myglobal.X()));
01009 MyScintHit->X[0] = float(myglobal.X());
01010 MyScintHit->Y[0] = float(myglobal.Y());
01011 MyScintHit->Z[0] = float(myglobal.Z());
01012 MyScintHit->T[0] = float(ScintHit->T1());
01013
01014 mylocal.SetXYZ( ScintHit->X2(), ScintHit->Y2(), ScintHit->Z2() );
01015 myglobal = ush.LocalToGlobal(mylocal);
01016
01017 MyScintHit->U[1] = float(0.7071*(myglobal.Y()+myglobal.X()));
01018 MyScintHit->V[1] = float(0.7071*(myglobal.Y()-myglobal.X()));
01019 MyScintHit->X[1] = float(myglobal.X());
01020 MyScintHit->Y[1] = float(myglobal.Y());
01021 MyScintHit->Z[1] = float(myglobal.Z());
01022 MyScintHit->T[1] = float(ScintHit->T2());
01023
01024 MyScintHit->DS = float(ScintHit->DS());
01025 MyScintHit->DE = float(ScintHit->DE());
01026 MyScintHit->ParticleE = float(ScintHit->ParticleEnergy());
01027
01028 idnu = fEvent->MCInfo.IDnu;
01029 trkid = ScintHit->TrackId();
01030 ipdg = ScintHit->ParticleId();
01031
01032 if( trkid>=0
01033 && ( (idnu==0 && (ipdg==13 || ipdg==-13) )
01034 || (idnu==14 && ipdg==13) || (idnu==-14 && ipdg==-13) ) )
01035 {
01036 plane = ScintHit->Plane();
01037 strip = ScintHit->Strip();
01038 x = myglobal.X(); y = myglobal.Y(); z = myglobal.Z();
01039 u = 0.7071*(y + x); v = 0.7071*(y - x);
01040 pmu = ScintHit->ParticleEnergy();
01041
01042 r=999.9;
01043 up=4.0-u; if(up<r) r=up;
01044 um=4.0+u; if(um<r) r=um;
01045 vp=4.0-v; if(vp<r) r=vp;
01046 vm=4.0+v; if(vm<r) r=vm;
01047 xp=4.0-x; if(xp<r) r=xp;
01048 xm=4.0+x; if(xm<r) r=xm;
01049 yp=4.0-y; if(yp<r) r=yp;
01050 ym=4.0+y; if(ym<r) r=ym;
01051
01052 if( minpmu<0 || pmu<minpmu )
01053 {
01054 muendU=u; muendV=v;
01055 muendX=x; muendY=y; muendZ=z; muendR=r;
01056 muendstrp=strip; muendpln=plane; minpmu=pmu;
01057 }
01058 if( maxpmu<0 || pmu>maxpmu )
01059 {
01060 muvtxU=u; muvtxV=v;
01061 muvtxX=x; muvtxY=y; muvtxZ=z; muvtxR=r;
01062 muvtxstrp=strip; muvtxpln=plane; maxpmu=pmu;
01063 }
01064 }
01065 }
01066
01067 fEvent->MCInfo.MuVtxU = muvtxU;
01068 fEvent->MCInfo.MuVtxV = muvtxV;
01069 fEvent->MCInfo.MuVtxX = muvtxX;
01070 fEvent->MCInfo.MuVtxY = muvtxY;
01071 fEvent->MCInfo.MuVtxZ = muvtxZ;
01072 fEvent->MCInfo.MuVtxDistToEdge = muvtxR;
01073 fEvent->MCInfo.MuVtxPlane = muvtxpln;
01074 fEvent->MCInfo.MuVtxStrip = muvtxstrp;
01075 fEvent->MCInfo.MuEndU = muendU;
01076 fEvent->MCInfo.MuEndV = muendV;
01077 fEvent->MCInfo.MuEndX = muendX;
01078 fEvent->MCInfo.MuEndY = muendY;
01079 fEvent->MCInfo.MuEndZ = muendZ;
01080 fEvent->MCInfo.MuEndDistToEdge = muendR;
01081 fEvent->MCInfo.MuEndPlane = muendpln;
01082 fEvent->MCInfo.MuEndStrip = muendstrp;
01083 fEvent->MCInfo.MuPbeg = maxpmu;
01084 fEvent->MCInfo.MuPend = minpmu;
01085
01086 }
01087 }
01088
01089 return;
01090 }
01091
01092
01093
01094 void NtpMaker::FillRawInfo(RawRecord* rawrec)
01095 {
01096 MSG("NtpMaker",Msg::kDebug) << " *** NtpMaker::FillRawInfo(...) *** " << endl;
01097
01098 const VldContext& vldc = *(rawrec->GetVldContext());
01099 this->FillSpillInfo(vldc);
01100
01101 return;
01102 }
01103
01104
01105
01106 void NtpMaker::FillShieldInfo(TObject* tob)
01107 {
01108 FarDetShieldPlankListHandle* ShldList = (FarDetShieldPlankListHandle*)(tob);
01109 MSG("NtpMaker",Msg::kDebug) << " ... found FarDetShieldPlankListHandle " << endl;
01110 TClonesArray& MyShldList = *(fEvent->ShieldPlankList);
01111
01112 TIter ShldItr(ShldList->GetDaughterIterator());
01113 while(FarDetShieldPlankHandle* Shld = (FarDetShieldPlankHandle*)(ShldItr()))
01114 {
01115 AtmosShieldPlank* MyShld = new( MyShldList[(fEvent->NShieldPlanks)++] ) AtmosShieldPlank();
01116
01117 MyShld->Section = Shld->GetSection();
01118 MyShld->SubSection = Shld->GetSubSection();
01119 MyShld->Plane = Shld->GetPlane();
01120 MyShld->Plank = Shld->GetPlank();
01121 MyShld->Nstrips = Shld->GetNStrips();
01122 MyShld->Nerrors = Shld->GetGeomErrors();
01123 MyShld->Ndigits = Shld->GetNDaughters();
01124 MyShld->X = Shld->GetX();
01125 MyShld->Y = Shld->GetY();
01126 MyShld->Z[0] = Shld->GetZ(StripEnd::kNegative);
01127 MyShld->Z[1] = Shld->GetZ(StripEnd::kPositive);
01128 MyShld->Traw[0] = Shld->GetTime(StripEnd::kNegative,CalTimeType::kNone);
01129 MyShld->Traw[1] = Shld->GetTime(StripEnd::kPositive,CalTimeType::kNone);
01130 MyShld->Tcal[0] = Shld->GetTime(StripEnd::kNegative,CalTimeType::kT0);
01131 MyShld->Tcal[1] = Shld->GetTime(StripEnd::kPositive,CalTimeType::kT0);
01132 MyShld->Qadc[0] = Shld->GetCharge(StripEnd::kNegative,CalDigitType::kNone);
01133 MyShld->Qadc[1] = Shld->GetCharge(StripEnd::kPositive,CalDigitType::kNone);
01134 MyShld->QPE[0] = Shld->GetCharge(StripEnd::kNegative,CalDigitType::kPE);
01135 MyShld->QPE[1] = Shld->GetCharge(StripEnd::kPositive,CalDigitType::kPE);
01136
01137 MyShld->GreenFibre[0] = Shld->GetGreenFibre(StripEnd::kNegative);
01138 MyShld->GreenFibre[1] = Shld->GetGreenFibre(StripEnd::kPositive);
01139 MyShld->WlsPigtail[0] = Shld->GetWlsPigtail(StripEnd::kNegative);
01140 MyShld->WlsPigtail[1] = Shld->GetWlsPigtail(StripEnd::kPositive);
01141 MyShld->ClearFibre[0] = Shld->GetClearFibre(StripEnd::kNegative);
01142 MyShld->ClearFibre[1] = Shld->GetClearFibre(StripEnd::kPositive);
01143
01144 }
01145 return;
01146 }
01147
01148
01149
01150 void NtpMaker::FillShowerInfo(TObject* tob)
01151 {
01152 CandShowerListHandle* ShwList = (CandShowerListHandle*)(tob);
01153 MSG("NtpMaker",Msg::kDebug) << " ... found CandShowerListHandle containing "<<ShwList->GetNDaughters()<<" showers."<< endl;
01154 float nstripcalib(0.0), nshwstrips(0.0);
01155 Calibrator& cal = Calibrator::Instance();
01156 TClonesArray* MyStrpList = (TClonesArray*)(fEvent->StripList);
01157
01158
01159 TClonesArray& MyShwList = *(fEvent->ShowerList);
01160 TIter ShwItr(ShwList->GetDaughterIterator());
01161 while(CandShowerHandle* Shw = (CandShowerHandle*)(ShwItr()))
01162 {
01163 AtmosShower* MyShw = new( MyShwList[(fEvent->NShowers)++] ) AtmosShower();
01164
01165 MyShw->VtxPlane = Shw->GetVtxPlane();
01166 MyShw->VtxTime = Shw->GetVtxT();
01167 MyShw->VtxU = Shw->GetVtxU();
01168 MyShw->VtxV = Shw->GetVtxV();
01169 MyShw->VtxR = sqrt((MyShw->VtxU*MyShw->VtxU)+(MyShw->VtxV*MyShw->VtxV));
01170 MyShw->VtxX = 0.7071*(Shw->GetVtxU()-Shw->GetVtxV());
01171 MyShw->VtxY = 0.7071*(Shw->GetVtxU()+Shw->GetVtxV());
01172 MyShw->VtxZ = Shw->GetVtxZ();
01173
01174 MyShw->VtxDirCosU = Shw->GetDirCosU();
01175 MyShw->VtxDirCosV = Shw->GetDirCosV();
01176 MyShw->VtxDirCosX = 0.7071*(Shw->GetDirCosU()-Shw->GetDirCosV());
01177 MyShw->VtxDirCosY = 0.7071*(Shw->GetDirCosU()+Shw->GetDirCosV());
01178 MyShw->VtxDirCosZ = Shw->GetDirCosZ();
01179 MyShw->TimeSlope = Shw->GetTimeSlope();
01180 MyShw->TimeOffset = Shw->GetTimeOffset();
01181 MyShw->Energy = Shw->GetEnergy();
01182
01183 MyShw->Nstrips = Shw->GetNStrip();
01184 MyShw->Nplanes = Shw->GetNPlane();
01185 MyShw->Index = (int)pow(2.,fEvent->NShowers-1);
01186
01187
01188 nshwstrips=Shw->GetNDaughters(); nstripcalib=0.0;
01189 TIter StrpItr(Shw->GetDaughterIterator());
01190 PlexStripEndId* seidP = 0;
01191 PlexStripEndId* seidN = 0;
01192 while(CandStripHandle* ShwStrp = (CandStripHandle*)(StrpItr()))
01193 {
01194 for(Int_t myint=0;myint<fEvent->NStrips;myint++)
01195 {
01196 AtmosStrip& MyStrp = *((AtmosStrip*)(MyStrpList->At(myint)));
01197 if( ShwStrp->GetPlane()==MyStrp.Plane && ShwStrp->GetStrip()==MyStrp.Strip )
01198 {
01199 if( MyStrp.Trk==0 && MyStrp.Shw==0 && Shw->GetU(MyStrp.Plane)>-999.9 && Shw->GetV(MyStrp.Plane)>-999.9 )
01200 {
01201
01202 if( MyStrp.View==0 )
01203 {
01204 MyStrp.L = Shw->GetV(MyStrp.Plane);
01205 MyStrp.GreenFibre[0] = MyStrp.HalfLength - MyStrp.L;
01206 MyStrp.GreenFibre[1] = MyStrp.HalfLength + MyStrp.L;
01207 seidN = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kNegative, StripEnd::kWhole, PlaneView::kU, PlaneCoverage::kTotal);
01208 seidP = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kPositive, StripEnd::kWhole, PlaneView::kU, PlaneCoverage::kTotal);
01209 }
01210 if( MyStrp.View==1 )
01211 {
01212 MyStrp.L = Shw->GetU(MyStrp.Plane);
01213 MyStrp.GreenFibre[0] = MyStrp.HalfLength + MyStrp.L;
01214 MyStrp.GreenFibre[1] = MyStrp.HalfLength - MyStrp.L;
01215 seidN = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kNegative, StripEnd::kWhole, PlaneView::kV, PlaneCoverage::kTotal);
01216 seidP = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kPositive, StripEnd::kWhole, PlaneView::kV, PlaneCoverage::kTotal);
01217 }
01218 double lsign = pow(-1.0, (1.0+double(MyStrp.View)) );
01219 if(seidN && MyStrp.Sigcorr[0]>0.0)
01220 {
01221 MyStrp.Sigmap[0] = cal.GetAttenCorrected(MyStrp.Sigcorr[0], lsign*MyStrp.L, *(seidN) );
01222 MyStrp.MIP[0] = cal.GetMIP(MyStrp.Sigmap[0], *(seidN) );
01223 }
01224 if(seidP && MyStrp.Sigcorr[1]>0.0)
01225 {
01226 MyStrp.Sigmap[1] = cal.GetAttenCorrected(MyStrp.Sigcorr[1], lsign*MyStrp.L, *(seidP) );
01227 MyStrp.MIP[1] = cal.GetMIP(MyStrp.Sigmap[1], *(seidP) );
01228 }
01229 }
01230 if(MyStrp.Sigcorr[0]>0.0 || MyStrp.Sigcorr[1]>0.0) nstripcalib+=1.0;
01231 MyStrp.Shw += MyShw->Index;
01232 }
01233
01234 if(seidP) delete seidP; seidP = 0;
01235 if(seidN) delete seidN; seidN = 0;
01236 }
01237 }
01238 MSG("NtpMaker",Msg::kVerbose) <<" "<<(int)nshwstrips<<" strips in the shower of which "<<(int)nstripcalib<<" were calibrated."<<endl<<flush;
01239 }
01240 return;
01241 }
01242
01243
01244
01245 void NtpMaker::FillSliceInfo(TObject* tob)
01246 {
01247 FarDetSliceListHandle* SliceList = (FarDetSliceListHandle*)(tob);
01248 MSG("NtpMaker",Msg::kDebug) << " ... found FarDetSliceListHandle " << endl;
01249
01250 TIter SliceItr = SliceList->GetDaughterIterator();
01251 FarDetSliceHandle* Slice = dynamic_cast<FarDetSliceHandle*>(SliceItr());
01252 if( Slice )
01253 {
01254 fEvent->FilterInfo.EventId = Slice->GetEventId();
01255 fEvent->FilterInfo.EventIdSM1 = Slice->GetEventIdSM1();
01256 fEvent->FilterInfo.EventIdSM2 = Slice->GetEventIdSM2();
01257 fEvent->FilterInfo.EventIdX = Slice->GetEventIdX();
01258 fEvent->FilterInfo.Edges=Slice->GetEdges();
01259 fEvent->FilterInfo.EdgesSM1=Slice->GetEdgesSM1();
01260 fEvent->FilterInfo.EdgesSM2=Slice->GetEdgesSM2();
01261 fEvent->FilterInfo.GoodUPlanes = Slice->GetGoodUPlanes();
01262 fEvent->FilterInfo.GoodVPlanes = Slice->GetGoodVPlanes();
01263 fEvent->FilterInfo.GoodPlanes = Slice->GetGoodPlanes();
01264 fEvent->FilterInfo.GoodStrips = Slice->GetGoodStrips();
01265 fEvent->FilterInfo.FidCharge = Slice->GetFidCharge();
01266 fEvent->FilterInfo.TotalCharge = Slice->GetTotalCharge();
01267 fEvent->FilterInfo.MaxPlaneCharge = Slice->GetMaxPlaneCharge();
01268
01269 for(Int_t myint=0; myint<11; myint++)
01270 {
01271 fEvent->FilterInfo.FidChargeSM1[myint] = Slice->GetFidChargeSM1(myint);
01272 fEvent->FilterInfo.FidChargeSM2[myint] = Slice->GetFidChargeSM2(myint);
01273 fEvent->FilterInfo.MeanXPosSM1[myint] = Slice->GetMeanXPosSM1(myint);
01274 fEvent->FilterInfo.MeanXPosSM2[myint] = Slice->GetMeanXPosSM2(myint);
01275 fEvent->FilterInfo.MeanYPosSM1[myint] = Slice->GetMeanYPosSM1(myint);
01276 fEvent->FilterInfo.MeanYPosSM2[myint] = Slice->GetMeanYPosSM2(myint);
01277 fEvent->FilterInfo.MeanZPosSM1[myint] = Slice->GetMeanZPosSM1(myint);
01278 fEvent->FilterInfo.MeanZPosSM2[myint] = Slice->GetMeanZPosSM2(myint);
01279 }
01280 }
01281 return;
01282 }
01283
01284
01285
01286 void NtpMaker::FillSpillInfo(const VldContext& vldc)
01287 {
01288 MSG("NtpMaker",Msg::kDebug) << " *** NtpMaker::FillSpillInfo(...) *** " << endl;
01289 double dt1(0.0),dt2(0.0),dt(0.0);
01290
01291
01292 if(vldc.GetSimFlag()==SimFlag::kData)
01293 {
01294
01295 SpillTimeFinder &stf = SpillTimeFinder::Instance();
01296 fEvent->SpillInfo.stfDataAvailable = stf.DataIsAvailable(vldc);
01297 fEvent->SpillInfo.TimeToNearestSpill_stf = stf.GetTimeToNearestSpill(vldc);
01298
01299 const SpillTimeND& ndspill = stf.GetNearestSpill(vldc);
01300
01301 const BeamMonSpill* bmspill = BDSpillAccessor::Get().LoadSpill(vldc.GetTimeStamp());
01302
01303
01304 if( bmspill )
01305 {
01306 VldTimeStamp ndspilltime = ndspill.GetTimeStamp();
01307 VldTimeStamp bmspilltime = bmspill->SpillTime();
01308 dt1 = bmspilltime.GetSec() - ndspilltime.GetSec();
01309 dt2 = ( bmspilltime.GetNanoSec() - ndspilltime.GetNanoSec() )*1e-9;
01310 dt = dt1 + dt2;
01311
01312 fEvent->SpillInfo.bmsDataAvailable = false;
01313 fEvent->SpillInfo.TimeToNearestSpill_bms = fEvent->SpillInfo.TimeToNearestSpill_stf + dt;
01314
01315 if( abs(fEvent->SpillInfo.TimeToNearestSpill_stf)<86400.0 )
01316 {
01317 fEvent->SpillInfo.bmsDataAvailable = true;
01318
01319
01320 fEvent->SpillInfo.beam_type = bmspill->BeamType();
01321 fEvent->SpillInfo.bmsStatus = bmspill->GetStatusInt();
01322
01323 BeamMonSpill::StatusBits status_bits = bmspill->GetStatusBits();
01324 fEvent->SpillInfo.horn_on = status_bits.horn_on;
01325 fEvent->SpillInfo.target_in = status_bits.target_in;
01326 fEvent->SpillInfo.n_batches = status_bits.n_batches;
01327
01328
01329 fEvent->SpillInfo.tor101 = bmspill->fTor101;
01330 fEvent->SpillInfo.tr101d = bmspill->fTr101d;
01331 fEvent->SpillInfo.tortgt = bmspill->fTortgt;
01332 fEvent->SpillInfo.trtgtd = bmspill->fTrtgtd;
01333 fEvent->SpillInfo.horncur = bmspill->fHornCur;
01334 for (Int_t i=0;i<6;++i)
01335 {
01336 fEvent->SpillInfo.bposx[i]=bmspill->fTargBpmX[i];
01337 fEvent->SpillInfo.bposy[i]=bmspill->fTargBpmY[i];
01338 fEvent->SpillInfo.bpmint[i]=bmspill->fBpmInt[i];
01339 }
01340 fEvent->SpillInfo.bwidx = bmspill->fProfWidX;
01341 fEvent->SpillInfo.bwidy = bmspill->fProfWidY;
01342 fEvent->SpillInfo.hadint = bmspill->fHadInt;
01343 fEvent->SpillInfo.muint1 = bmspill->fMuInt1;
01344 fEvent->SpillInfo.muint2 = bmspill->fMuInt2;
01345 fEvent->SpillInfo.muint3 = bmspill->fMuInt3;
01346
01347 VldTimeStamp BMsubtime = bmspilltime-ndspill.GetTimeStamp();
01348 BMSpillAna BMana;
01349 BMana.UseDatabaseCuts();
01350 BMana.SetSpill(*bmspill);
01351 BMana.SetTimeDiff(BMsubtime.GetSeconds());
01352 fEvent->SpillInfo.BeamSelectSpill = BMana.SelectSpill();
01353 }
01354 }
01355 else
01356 {
01357 MSG("NtpMaker",Msg::kDebug)<< "No BeamMonSpill found!" <<endl;
01358 }
01359
01360 }
01361
01362 return;
01363 }
01364
01365
01366
01367 void NtpMaker::FillStripInfo(TObject* tob)
01368 {
01369 FarDetStripListHandle* StrpList = (FarDetStripListHandle*)(tob);
01370 MSG("NtpMaker",Msg::kDebug) << " ... found FarDetStripListHandle " << endl;
01371 TClonesArray& MyStrpList = *(fEvent->StripList);
01372 Calibrator& cal = Calibrator::Instance();
01373 float nstripcalib(0.0);
01374 Int_t pln;
01375 Double_t totq,totqo,opos;
01376
01377 TIter StrpItr(StrpList->GetDaughterIterator());
01378 while(FarDetStripHandle* Strp = dynamic_cast<FarDetStripHandle*>(StrpItr()))
01379 {
01380 AtmosStrip* MyStrp = new( MyStrpList[ (fEvent->NStrips)++] ) AtmosStrip();
01381
01382 MyStrp->Plane = Strp->GetPlane();
01383 MyStrp->Strip = Strp->GetStrip();
01384 if(Strp->GetPlaneView()==PlaneView::kU) MyStrp->View = 0;
01385 if(Strp->GetPlaneView()==PlaneView::kV) MyStrp->View = 1;
01386 MyStrp->L = 0.0;
01387 MyStrp->T = Strp->GetTPos();
01388 MyStrp->Z = Strp->GetZPos();
01389 MyStrp->Ndigits = Strp->GetNDaughters();
01390 MyStrp->Traw[0] = Strp->GetTime(StripEnd::kNegative,CalTimeType::kNone);
01391 MyStrp->Traw[1] = Strp->GetTime(StripEnd::kPositive,CalTimeType::kNone);
01392 MyStrp->Tcal[0] = Strp->GetTime(StripEnd::kNegative,CalTimeType::kT0);
01393 MyStrp->Tcal[1] = Strp->GetTime(StripEnd::kPositive,CalTimeType::kT0);
01394 MyStrp->Qadc[0] = Strp->GetCharge(StripEnd::kNegative,CalDigitType::kNone);
01395 MyStrp->Qadc[1] = Strp->GetCharge(StripEnd::kPositive,CalDigitType::kNone);
01396 MyStrp->QPE[0] = Strp->GetCharge(StripEnd::kNegative,CalDigitType::kPE);
01397 MyStrp->QPE[1] = Strp->GetCharge(StripEnd::kPositive,CalDigitType::kPE);
01398 MyStrp->Sigcorr[0] = Strp->GetCharge(StripEnd::kNegative,CalDigitType::kSigCorr);
01399 MyStrp->Sigcorr[1] = Strp->GetCharge(StripEnd::kPositive,CalDigitType::kSigCorr);
01400 MyStrp->QPEcorr[0] = MyStrp->Sigcorr[0]/65.0;
01401 MyStrp->QPEcorr[1] = MyStrp->Sigcorr[1]/65.0;
01402 MyStrp->GreenFibre[0] = Strp->GetGreenFibre(StripEnd::kNegative);
01403 MyStrp->GreenFibre[1] = Strp->GetGreenFibre(StripEnd::kPositive);
01404 MyStrp->WlsPigtail[0] = Strp->GetWlsPigtail(StripEnd::kNegative);
01405 MyStrp->WlsPigtail[1] = Strp->GetWlsPigtail(StripEnd::kPositive);
01406 MyStrp->ClearFibre[0] = Strp->GetClearFibre(StripEnd::kNegative);
01407 MyStrp->ClearFibre[1] = Strp->GetClearFibre(StripEnd::kPositive);
01408 MyStrp->HalfLength = Strp->GetHalfLength();
01409 MyStrp->Xtalk = Strp->IsXtalk(StripEnd::kWhole);
01410
01411 if( MyStrp->Plane>0 && MyStrp->Plane<500 && MyStrp->Xtalk==0 && MyStrp->QPE[0]+MyStrp->QPE[1]>2.0 )
01412 {
01413 fStrpList[MyStrp->Plane].push_back(*MyStrp);
01414 }
01415 }
01416 vector<AtmosStrip>::iterator PlaneStrpIter;
01417 vector<AtmosStrip>::iterator PlaneListEnd;
01418 PlexStripEndId* seidP = 0;
01419 PlexStripEndId* seidN = 0;
01420 for(Int_t myint=0;myint<fEvent->NStrips;myint++)
01421 {
01422 AtmosStrip& MyStrp = *((AtmosStrip*)(MyStrpList.At(myint)));
01423 pln = MyStrp.Plane;
01424
01425 totqo=0.0; totq=0.0; opos=0.0;
01426 if( (pln>1 && pln<249) || (pln>250 && pln<498) )
01427 {
01428 PlaneStrpIter = fStrpList[pln-1].begin();
01429 PlaneListEnd = fStrpList[pln-1].end();
01430 while(PlaneStrpIter!=PlaneListEnd)
01431 {
01432 AtmosStrip& mystrip = *(PlaneStrpIter);
01433 totqo+=(mystrip.QPE[0]+mystrip.QPE[1])*(mystrip.T);
01434 totq+=(mystrip.QPE[0]+mystrip.QPE[1]);
01435 ++PlaneStrpIter;
01436 }
01437 }
01438 if( (pln>0 && pln<248) || (pln>249 && pln<497) )
01439 {
01440 PlaneStrpIter = fStrpList[pln+1].begin();
01441 PlaneListEnd = fStrpList[pln+1].end();
01442 while(PlaneStrpIter!=PlaneListEnd)
01443 {
01444 AtmosStrip& mystrip = *(PlaneStrpIter);
01445 totqo+=(mystrip.QPE[0]+mystrip.QPE[1])*(mystrip.T);
01446 totq+=(mystrip.QPE[0]+mystrip.QPE[1]);
01447 ++PlaneStrpIter;
01448 }
01449 }
01450 if(totq>0.0){ opos=totqo/totq; } else{ opos=0.0; }
01451
01452 MyStrp.L = opos;
01453 if( MyStrp.View==0 )
01454 {
01455 MyStrp.GreenFibre[0] = MyStrp.HalfLength - MyStrp.L;
01456 MyStrp.GreenFibre[1] = MyStrp.HalfLength + MyStrp.L;
01457 seidN = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kNegative, StripEnd::kWhole, PlaneView::kU, PlaneCoverage::kTotal);
01458 seidP = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kPositive, StripEnd::kWhole, PlaneView::kU, PlaneCoverage::kTotal);
01459 }
01460 if( MyStrp.View==1 )
01461 {
01462 seidN = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kNegative, StripEnd::kWhole, PlaneView::kV, PlaneCoverage::kTotal);
01463 seidP = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kPositive, StripEnd::kWhole, PlaneView::kV, PlaneCoverage::kTotal);
01464 MyStrp.GreenFibre[0] = MyStrp.HalfLength + MyStrp.L;
01465 MyStrp.GreenFibre[1] = MyStrp.HalfLength - MyStrp.L;
01466 }
01467
01468 double lsign = pow(-1.0, (1.0+double(MyStrp.View)) );
01469 if(seidN && MyStrp.Sigcorr[0]>0.0)
01470 {
01471 MyStrp.Sigmap[0] = cal.GetAttenCorrected(MyStrp.Sigcorr[0], lsign*opos, *(seidN) );
01472 MyStrp.MIP[0] = cal.GetMIP(MyStrp.Sigmap[0], *(seidN) );
01473 }
01474 if(seidP && MyStrp.Sigcorr[1]>0.0)
01475 {
01476 MyStrp.Sigmap[1] = cal.GetAttenCorrected(MyStrp.Sigcorr[1], lsign*opos, *(seidP) );
01477 MyStrp.MIP[1] = cal.GetMIP(MyStrp.Sigmap[1], *(seidP) );
01478 }
01479 if(MyStrp.Sigcorr[0]>0.0 || MyStrp.Sigcorr[1]>0.0) nstripcalib+=1.0;
01480
01481 if(seidP) delete seidP; seidP = 0;
01482 if(seidN) delete seidN; seidN = 0;
01483 }
01484 MSG("NtpMaker",Msg::kVerbose) <<" "<<(int)(fEvent->NStrips)<<" strips in the event of which "<<(int)nstripcalib<< " were calibrated."<<endl<<flush;
01485
01486 for(Int_t myi=0;myi<500;myi++)
01487 {
01488 fStrpList[myi].clear();
01489 }
01490 return;
01491 }
01492
01493
01494
01495 void NtpMaker::FillTrackInfo(TObject* tob)
01496 {
01497 CandTrackListHandle* TrkList = (CandTrackListHandle*)(tob);
01498 MSG("NtpMaker",Msg::kDebug) << " ... found CandTrackListHandle containing "<<TrkList->GetNDaughters()<<" tracks."<< endl;
01499 float nstripcalib(0.0),stripsintrack(0.0);
01500 Calibrator& cal = Calibrator::Instance();
01501 TClonesArray* MyStrpList = (TClonesArray*)(fEvent->StripList);
01502
01503
01504 TClonesArray& MyTrkList = *(fEvent->TrackList);
01505 TIter TrkItr = TrkList->GetDaughterIterator();
01506 while(CandTrackHandle* Trk = dynamic_cast<CandTrackHandle*>(TrkItr()))
01507 {
01508 AtmosTrack* MyTrk = new( MyTrkList[(fEvent->NTracks)++] ) AtmosTrack();
01509 MyTrk->VtxPlane = Trk->GetVtxPlane();
01510 MyTrk->VtxTime = Trk->GetVtxT();
01511 MyTrk->VtxU = Trk->GetVtxU();
01512 MyTrk->VtxV = Trk->GetVtxV();
01513 MyTrk->VtxR = sqrt( (MyTrk->VtxU*MyTrk->VtxU) + (MyTrk->VtxV*MyTrk->VtxV) );
01514 MyTrk->VtxX = 0.7071*(Trk->GetVtxU()-Trk->GetVtxV());
01515 MyTrk->VtxY = 0.7071*(Trk->GetVtxU()+Trk->GetVtxV());
01516 MyTrk->VtxZ = Trk->GetVtxZ();
01517 MyTrk->VtxTrace = Trk->GetVtxTrace();
01518 MyTrk->VtxTraceZ = Trk->GetVtxTraceZ();
01519 MyTrk->VtxDirCosU = Trk->GetDirCosU();
01520 MyTrk->VtxDirCosV = Trk->GetDirCosV();
01521 MyTrk->VtxDirCosX = 0.7071*(Trk->GetDirCosU()-Trk->GetDirCosV());
01522 MyTrk->VtxDirCosY = 0.7071*(Trk->GetDirCosU()+Trk->GetDirCosV());
01523 MyTrk->VtxDirCosZ = Trk->GetDirCosZ();
01524 MyTrk->EndPlane = Trk->GetEndPlane();
01525 MyTrk->EndTime = Trk->GetEndT();
01526 MyTrk->EndU = Trk->GetEndU();
01527 MyTrk->EndV = Trk->GetEndV();
01528 MyTrk->EndR = sqrt((MyTrk->EndU*MyTrk->EndU)+(MyTrk->EndV*MyTrk->EndV));
01529 MyTrk->EndX = 0.7071*(Trk->GetEndU()-Trk->GetEndV());
01530 MyTrk->EndY = 0.7071*(Trk->GetEndU()+Trk->GetEndV());
01531 MyTrk->EndZ = Trk->GetEndZ();
01532 MyTrk->EndTrace = Trk->GetEndTrace();
01533 MyTrk->EndTraceZ = Trk->GetEndTraceZ();
01534 MyTrk->EndDirCosU = Trk->GetEndDirCosU();
01535 MyTrk->EndDirCosV = Trk->GetEndDirCosV();
01536 MyTrk->EndDirCosX = 0.7071*(Trk->GetEndDirCosU()-Trk->GetEndDirCosV());
01537 MyTrk->EndDirCosY = 0.7071*(Trk->GetEndDirCosU()+Trk->GetEndDirCosV());
01538 MyTrk->EndDirCosZ = Trk->GetEndDirCosZ();
01539 MyTrk->RangeGCM2 = Trk->GetRange(Trk->GetEndPlane());
01540
01541 MyTrk->RangeMetres = Trk->GetdS(Trk->GetEndPlane());
01542
01543 MyTrk->Nstrips = Trk->GetNStrip();
01544 MyTrk->Nplanes = abs(MyTrk->EndPlane-MyTrk->VtxPlane)+1;
01545 MyTrk->AtNuNplanes = MyTrk->Nplanes;
01546
01547 MyTrk->TimingFitChi2 = Trk->GetTimeFitChi2();
01548 MyTrk->TimingFitNdf = Trk->GetNTimeFitDigit()-2;
01549 MyTrk->TimeSlope = Trk->GetTimeSlope();
01550 MyTrk->TimeOffset = Trk->GetTimeOffset();
01551
01552 if(MyTrk->EndPlane-MyTrk->VtxPlane>0)
01553 {
01554 MyTrk->VtxDirTimeFitRMS = Trk->GetTimeForwardFitRMS();
01555 MyTrk->EndDirTimeFitRMS = Trk->GetTimeBackwardFitRMS();
01556 MyTrk->VtxDirTimeFitNdf = Trk->GetTimeForwardFitNDOF();
01557 MyTrk->EndDirTimeFitNdf = Trk->GetTimeBackwardFitNDOF();
01558 }
01559 else
01560 {
01561 MyTrk->VtxDirTimeFitRMS = Trk->GetTimeBackwardFitRMS();
01562 MyTrk->EndDirTimeFitRMS = Trk->GetTimeForwardFitRMS();
01563 MyTrk->VtxDirTimeFitNdf = Trk->GetTimeBackwardFitNDOF();
01564 MyTrk->EndDirTimeFitNdf = Trk->GetTimeForwardFitNDOF();
01565 }
01566
01567 MyTrk->Momentum = Trk->GetMomentum();
01568 MyTrk->MomentumRange = Trk->GetMomentum();
01569
01570 MyTrk->Index = (int)pow(2.,fEvent->NTracks-1);
01571
01572
01573 TIter StrpItr(Trk->GetDaughterIterator());
01574 nstripcalib=(0.0); stripsintrack = Trk->GetNDaughters();
01575 PlexStripEndId* seidP = 0;
01576 PlexStripEndId* seidN = 0;
01577 while(CandStripHandle* TrkStrp = (CandStripHandle*)(StrpItr()))
01578 {
01579 for(Int_t myint=0;myint<fEvent->NStrips;myint++)
01580 {
01581 AtmosStrip& MyStrp = *((AtmosStrip*)(MyStrpList->At(myint)));
01582
01583 if( TrkStrp->GetPlane()==MyStrp.Plane && TrkStrp->GetStrip()==MyStrp.Strip )
01584 {
01585 if( MyStrp.Trk==0 && Trk->IsTPosValid(MyStrp.Plane) )
01586 {
01587 if( MyStrp.View==0 )
01588 {
01589 MyStrp.L = Trk->GetV(MyStrp.Plane);
01590 MyStrp.dS = Trk->GetdS(MyStrp.Plane);
01591 MyStrp.GreenFibre[0] = MyStrp.HalfLength - MyStrp.L;
01592 MyStrp.GreenFibre[1] = MyStrp.HalfLength + MyStrp.L;
01593 seidN = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kNegative, StripEnd::kWhole, PlaneView::kU, PlaneCoverage::kTotal);
01594 seidP = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kPositive, StripEnd::kWhole, PlaneView::kU, PlaneCoverage::kTotal);
01595 }
01596 if( MyStrp.View==1 )
01597 {
01598 MyStrp.L = Trk->GetU(MyStrp.Plane);
01599 MyStrp.dS = Trk->GetdS(MyStrp.Plane);
01600 MyStrp.GreenFibre[0] = MyStrp.HalfLength + MyStrp.L;
01601 MyStrp.GreenFibre[1] = MyStrp.HalfLength - MyStrp.L;
01602 seidN = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kNegative, StripEnd::kWhole, PlaneView::kV, PlaneCoverage::kTotal);
01603 seidP = new PlexStripEndId(Detector::kFar, MyStrp.Plane, MyStrp.Strip, StripEnd::kPositive, StripEnd::kWhole, PlaneView::kV, PlaneCoverage::kTotal);
01604 }
01605 double lsign = pow(-1.0, (1.0+double(MyStrp.View)) );
01606 if(seidN && MyStrp.Sigcorr[0]>0.0)
01607 {
01608 MyStrp.Sigmap[0] = cal.GetAttenCorrected(MyStrp.Sigcorr[0], lsign*MyStrp.L, *(seidN) );
01609 MyStrp.MIP[0] = cal.GetMIP(MyStrp.Sigmap[0], *(seidN) );
01610 }
01611 if(seidP && MyStrp.Sigcorr[1]>0.0)
01612 {
01613 MyStrp.Sigmap[1] = cal.GetAttenCorrected(MyStrp.Sigcorr[1], lsign*MyStrp.L, *(seidP) );
01614 MyStrp.MIP[1] = cal.GetMIP(MyStrp.Sigmap[1], *(seidP) );
01615 }
01616 if(MyStrp.Sigcorr[0]>0.0 || MyStrp.Sigcorr[1]>0.0) nstripcalib+=1.0;
01617 }
01618 MyStrp.Trk += MyTrk->Index;
01619
01620 if(seidP) delete seidP; seidP = 0;
01621 if(seidN) delete seidN; seidN = 0;
01622
01623 break;
01624
01625
01626 }
01627 }
01628 }
01629 MSG("NtpMaker",Msg::kVerbose) <<" "<<(int)stripsintrack<<" strips in the track of which "<<(int)nstripcalib<< " were calibrated."<<endl<<flush;
01630 }
01631 return;
01632 }
01633
01634
01635
01636